File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Step_13 Components/modules/ui/xml Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,27 @@ ui.xml.Table = class extends ui.Table {
2626 Composite . asynchron ( ( ) => {
2727 // Temporary a spinner is shown during loading.
2828 ui . spinner . append ( this . selector ) ;
29+
30+ // The data is loaded initially (if necessary).
31+ this . load ( ) ;
32+
33+ // The standard sorting is determined and applied.
34+ // To do this, the table must be rendered temporarily without
35+ // sorting so that the sortable fields can be determined.
2936 var sorting = null ;
37+ var fragment = this . render ( ) ;
38+ var nodes = Array . from ( fragment . querySelectorAll ( "thead" ) ) ;
39+ if ( nodes . length <= 0 )
40+ throw new Error ( "Invalid table structure: thead is missing" ) ;
41+ var column = fragment . querySelector ( "thead *.sortable.sortable-default[id]" ) ;
42+ if ( column ) {
43+ column = ( column . getAttribute ( "id" ) || "" ) . trim ( ) ;
44+ if ( column ) {
45+ sorting = { column, reverse :false }
46+ this . sort ( sorting . column , sorting . reverse ) ;
47+ }
48+ }
49+
3050 var output = table => {
3151 Composite . asynchron ( ( ) => {
3252 document . querySelector ( table . selector ) . appendChild ( table . render ( ) , true ) ;
You can’t perform that action at this time.
0 commit comments