@@ -63,9 +63,12 @@ document.addEventListener("DOMContentLoaded", function() {
63
63
input . addEventListener ( "change" , function ( e ) {
64
64
widget . filters [ idx ] = e . target . value ;
65
65
removeAllChildNodes ( tbody ) ;
66
+ elements = [ ] ;
66
67
rows . filter ( isFilterMatch ) . map ( r => {
67
68
tbody . appendChild ( r . el )
69
+ elements . push ( r )
68
70
} ) ;
71
+ console . log ( elements ) ;
69
72
} ) ;
70
73
input . setAttribute ( 'style' , 'width:100%;display:block' )
71
74
input . setAttribute ( 'type' , 'text' ) ;
@@ -104,6 +107,7 @@ document.addEventListener("DOMContentLoaded", function() {
104
107
columns, // Needed for filtered
105
108
} ;
106
109
} ) ;
110
+ let elements = rows ;
107
111
108
112
function addSortButton ( el , idx ) {
109
113
const img = document . createElement ( 'img' ) ;
@@ -118,30 +122,31 @@ document.addEventListener("DOMContentLoaded", function() {
118
122
119
123
let direction = false ;
120
124
function sortTable ( columnIndex ) {
125
+ console . log ( elements ) ;
121
126
removeAllChildNodes ( tbody ) ;
122
- if ( isNaN ( rows [ 0 ] . columns [ columnIndex ] [ 0 ] ) && isNaN ( rows [ rows . length - 1 ] . columns [ columnIndex ] [ 0 ] ) ) {
123
- rows . sort ( ( a , b ) => {
127
+ if ( isNaN ( elements [ 0 ] . columns [ columnIndex ] [ 0 ] ) && isNaN ( elements [ elements . length - 1 ] . columns [ columnIndex ] [ 0 ] ) ) {
128
+ elements . sort ( ( a , b ) => {
124
129
a = a . columns [ columnIndex ] ;
125
130
b = b . columns [ columnIndex ] ;
126
131
return direction ? a . localeCompare ( b ) : b . localeCompare ( a ) ;
127
132
} ) ;
128
133
} else {
129
134
if ( ! columnIndex && window . location . href . includes ( "docs/alerts" ) ) {
130
- rows . sort ( ( a , b ) => {
135
+ elements . sort ( ( a , b ) => {
131
136
a = a . columns [ columnIndex ] . split ( "-" ) ;
132
137
b = b . columns [ columnIndex ] . split ( "-" ) ;
133
138
return direction ? a [ 0 ] - b [ 0 ] : b [ 0 ] - a [ 0 ] ;
134
139
} ) ;
135
140
} else {
136
- rows . sort ( ( a , b ) => {
141
+ elements . sort ( ( a , b ) => {
137
142
a = a . columns [ columnIndex ] ;
138
143
b = b . columns [ columnIndex ] ;
139
144
return direction ? a - b : b - a ;
140
145
} ) ;
141
146
}
142
147
}
143
- for ( let i = 0 ; i <= rows . length - 1 ; i ++ ) {
144
- tbody . appendChild ( rows [ i ] . el ) ;
148
+ for ( let i = 0 ; i <= elements . length - 1 ; i ++ ) {
149
+ tbody . appendChild ( elements [ i ] . el ) ;
145
150
}
146
151
direction = ! direction ;
147
152
}
0 commit comments