Filter rows in CSV file
I have a 4 column grid. one column is called Publisher. i want to filter all rows in grid where Publisher="IBM". does anyone have any idea on how to do this with a CSV file. thanks for your help!!!!
Matt
March 9,
// var max = gridVar.getRowCount(); ///// FOR ARRAY DATA MODEL
// var max2 = max; ////// FOR ARRAY DATA MODEL
function filter(text, column){
var i, rows = [], max = table.getCount(); ///////// FOR ARRAY DATA MODEL USE: (in new line) max = gridVar.getRowCount();
if (text==''){
obj.setRowCount(max); ///////// FOR ARRAY DATA MODEL USE: max2
obj.setRowIndices('');
}
if (text !=''){
for (i=0; i<max; i++){ ///////// FOR ARRAY DATA MODEL USE: max2
if (obj.getCellValue(column, i).indexOf(text)> -1 ){
rows.push(i);
}
}
obj.setRowCount(rows.length);
obj.setRowIndices(rows);
}
obj.getRowsTemplate().refresh();
}
// var max = gridVar.getRowCount(); ///////// FOR ARRAY DATA MODEL
// var max2 = max; ///////// FOR ARRAY DATA MODEL
var filtersrunning = [];
function NestedFilter(searchcriteria,column){
searchcriteria = searchcriteria.toUpperCase();
var filters = filtersrunning ;
var i, rows = [], max = table.getCount(); ///////// FOR ARRAY DATA MODEL USE: (in new line) max = gridVar.getRowCount();
var samecolfound = false;
if(filtersrunning.length == 0 && searchcriteria !=''){ filters.push([column,searchcriteria] ) }
if(filtersrunning.length > 0 ){
for(var aa=0 ; aa<filtersrunning.length ; aa++){
if(filtersrunning[aa][0] == column){samecolfound = true }
}
for(var z=0 ; z<filtersrunning.length ; z++){
if(samecolfound ){
if( searchcriteria !='' && filtersrunning[z][0] == column ){ filters[z]=[column,searchcriteria] }
if( searchcriteria=='' && filtersrunning[z][0] == column ){ filters.splice(z,1) }
}
}
if( !samecolfound ){
if( searchcriteria !=''){ filters.push([column,searchcriteria] ) }
}
}
if(filters.length == 0 ){
obj.setRowCount(max); ///////// FOR ARRAY DATA MODEL USE: max2
obj.setRowIndices('');
//Lab.setControlText("FOUND: " + max);
obj.setRowCount(rows.length);
}
if(filters.length > 0 ){
for (rw=0; rw<max; rw++){ ///////// FOR ARRAY DATA MODEL USE: max2
var found =0;
for (Xcol=0; Xcol<filters.length; Xcol++){
if ( obj.getCellText(filters[Xcol][0], rw).toUpperCase().indexOf(filters[Xcol][1]) >-1 ){
found++ ;
}
}
if (found== filters.length) { rows.push(rw) }
}
obj.setRowCount(rows.length);
obj.setRowIndices(rows);
//Lab.setControlText("FOUND: " +rows.length);
}
filtersrunning = filters;
//Lab.refresh();
obj.getRowsTemplate().refresh();
}
This topic is archived.
ActiveWidgets is a javascript library for creating user interfaces. It offers excellent performance for complex screens while staying simple, compact and easy to learn. Deployed by thousands of commercial customers in more than 70 countries worldwide.
Copyright © ActiveWidgets 2021