:: Forum >>
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
Monday, November 14, 2005
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 =[];
for (i=0;i<myData.length;i++){ FilteredIndices.push(i) }
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
Tuesday, November 15, 2005
And you can filter sort and then filter more, but I forgot to "clear" the sort indicator after show-all.
Tuesday, November 15, 2005
Thanks for the quick responce.
It worked.
Alex
Tuesday, November 15, 2005
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
Thursday, November 17, 2005
This topic is archived.
Back to support forum
Forum search