:: Forum >>

Filtering grid results.

Hello,

I am looking for a way to select the distinct elements of a single column, put that in a select box outside the grid, and then filter the results against the selected item.

This seems simple but I have spent literally days trying to wade through these forum posts to find such a solution.


Thanks in advance for any suggestions.

Michael
Thursday, September 20, 2007
There is an example on filtering grid records in the XML Data Islands section.

You can also use XPath expressions to retrieve selective data from an XML file and load it into the grid.
Sumit Madan
Thursday, September 20, 2007
This example can only be used once and uses a fixed filter. I am looking for a select box which is created dynamically from the contents of a column to create the filter. I would also like to be able to clear the filter if possible.
Michael
Thursday, September 20, 2007
Kinda answering my own question. Since we seem to be on our own for documentation here it goes.


I think this is the best filtering example out there. Passing the search term as 'group' and the compared column as column. You can search more than once. Switch search terms. And clear out the filter by passing ''. The last two lines are added to bring the grid back to the top as I have not figured out how to reduce the rows in the grid without losing data.

//Filter Grid Results
function filterGridByGroup(column, group){
var i, rows = [], max = obj.getRowCount();
for (i=0; i<max; i++){
//alert(group+'|'+obj.getCellValue(column, i));
if (group == "" || obj.getCellValue(column, i) == group){
rows.push(i);
}
}
obj.setRowIndices(rows);
obj.setCurrentRow(0);
obj.refresh();
}


As two the first part of my question (selecting distinct elements) I am doing it serverside. On a 10000 row result I expect it will be faster.
Michael
Saturday, September 22, 2007

This topic is archived.


Back to support forum

Forum search