Skip to content

Commit f5eecd0

Browse files
committed
#0000 Tutorial: Update of content
1 parent 62ce9c5 commit f5eecd0

File tree

1 file changed

+20
-0
lines changed
  • Step_13 Components/modules/ui/xml

1 file changed

+20
-0
lines changed

Step_13 Components/modules/ui/xml/table.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)