SMART datagrid v.1 > Classes > GridDataSet

[ grids ver.1.3.8]   Back  Forward

DataLudi.GridDataSet.filterRows  method

将指定在filter参数的表达式或匹配回调函数的数据行的索引返回为数组。 

如果通过回调而指定,就会传递如下参数,而如果是包含在结果的行,就需要返回true。 

function (ds:GridDataSet, row, count): Boolean;

row是目前检讨中的数据行号,而count是目前已被添加的行数。 

可以被用于表达式的变量列表,已被列在下列表格。 

function filterRows (filter: String|Function, maxCount: Integer): [Integer];
Returns
[Integer]
Parameters
filter - String|Function. required.
maxCount - Integer. 默认值为-1.
将会被包含在所返回的数组的行的最大数量。 如果没有指定或是小于0的值,就会返回相关的所有行。
Table-1  expression变量
变量说明
'values获取各个字段的值为字段名称或索引。
'row'计算中的数据行索引。
Code -1
    // 公司名称以'a'开头,并且数量大于100的行。
    var rows = ds.filterRows(function (ds, row, count) {
        return ds.getValue(row, 'country').indexOf('a') == 0 && ds.getValue(row, 'qty') > 100;
    });
    rows = grid.getRowsOfDataIndices(rows);
    grid.checkAll(false);
    grid.checkRows(rows);
Code -2
    // 获取最多10个、数量大于100的行。
    var rows = ds.filterRows("values['qty'] > 100", 10);
    rows = grid.getRowsOfDataIndices(rows);
    grid.checkAll(false);
    grid.checkRows(rows);
See Also
findRows
findRow
Examples
网格数据组行