SMART datagrid v.1 > Examples

Back  Forward

Row Filtering  Example

When organize grid row models from DataSet, you can specify the row filter by Expression or callback function through rowFilter property to get the data rows only meeting the conditions. For example, in the grid below, it specifies the filters which only get "10 top rows (top n)", "10 bottom rows (bottom n)" or "display updated rows only"

Grid - 1
rows

   

Code -1
    grdMain.setRowFilter({
        // expression
        expression: "values['unit_price'] > 500 && values['quantity'] > 500", // values is v.1.3.9
        callback: null
        
        // or callback
        expression: null,
    	callback: function (row) {
    	    return row.getValue('unit_price') > 500 && row.getValue('quantity') > 500;
    	}
    });

 

Code -2
    grdMain.setRowFilter({
    	callback: null,
    	expression: "row < 10"
    });

 

Code -3
    grdMain.setRowFilter({
    	callback: null,
    	expression: "row >= rowcount - 10"
    });

  

Code -4
    grdMain.setRowFilter({
        expression: "state == 'u'",
        callback: null
    });

  

Code -5
    grdMain.setRowFilter({
    	expression: null,
    	callback: null
    });

Actually, Row Filter is managed by RowFilter object from the end of row model. And, since row filter is applied before column filters in row model level rather than grid, it will be reflected in the display of all grids which share the same row model. 

View Source JSP 

See Also
RowFilter
GridBase.rowFilter
Examples
Column Filtering