3.0.5

Problem with toggling column visibility and sorting

I have a small issue that I am trying to figure out.
Here is the code (you can put it in basic.html after document.write(obj).

obj.onSelectorClicked = function(event, index) {
//Hide rows below current one
obj.setRowCount(parseInt(index) + 1);
obj.refresh();
}
obj.onCellClicked = function(event, index) {
// Show all the rows
obj.setRowCount(myData.length);
obj.refresh();
}

As you can see I hide rows below selected on the header click and show them again on cell click. Works great.
The problem is when I sort the column while the data is hidden I get NaN for the data that was hidden when I attempt to show it again.

Any ideas?
Thanks.
Alex
November 14,
I have a "partial" solution, [should be a way] but can't construct RowIndices for all rows after sorting(when filtered) ,so it's a show all unsorted for now.
HTH

var RowsShown =[];
var FilteredIndices = [];
var AllIndicesSorted = [];

obj.onSelectorClicked = function(event, index) {

RowsShown =[];

////// fill a array with indices if unsorted
for (i=0;i<myData.length;i++){ FilteredIndices.push(i) } 

///// fill same array if sorted
if(obj.getRowIndices()){FilteredIndices = obj.getRowIndices()}

var lastrow = 0;

for (i=0;i<FilteredIndices.length;i++){
if(FilteredIndices[i] == parseInt(index)) { lastrow = i }
  }
for (i=0;i<lastrow+1;i++){ RowsShown.push(FilteredIndices[i]) }
  
obj.setRowCount(RowsShown.length);
obj.setRowIndices(RowsShown);
obj.refresh();
}

obj.onCellClicked = function(event, index) {

RowsShown =[];

for (i=0;i<myData.length;i++){ RowsShown.push(i) }
  
obj.setRowCount(myData.length);
obj.setRowIndices(RowsShown);
 
obj.refresh();
}
Carlos
November 15,
And you can filter sort and then filter more, but I forgot to "clear" the sort indicator after show-all.
November 15,
Thanks for the quick responce.
It worked.
Alex
November 15,
Found a solution to the sorting problem. Not the best solution but it works.

obj.onCellClicked = function(event, index) {
var RowsShown =[];
var sortCol = obj.getSortColumn();
var sortDir = obj.getSortDirection(sortCol);

for (i=0;i<myData.length;i++){ RowsShown.push(i); }

obj.setRowCount(myData.length);
obj.setRowIndices(RowsShown);
obj.sort(sortCol, sortDir); //<<< resort here.

obj.refresh();
}
Alex
November 17,

This topic is archived.

See also:


Back to support forum