SMART datagrid v.1 > Classes > GridBase

Back  Forward

DataLudi.GridBase.searchCell  method

Return information of the first grid cell which meets the conditions specified by parameters. 

If no corresponding cell, it will return null. In the table below, it will explain the properties of result object being returned. 

function searchCell (fields: Array, value: String, options: Object, startRowIndex: Number, startFieldIndex: Number, wrap: Boolean, select: Boolean): Object;
Returns
Object
Parameters
fields - Array.
It specifies fields which will be searched by field index or name.
value - String.
The search value.
options - Object.
The search condition. It will be described in the table below.
startRowIndex - Number.
The number of row from which will start searching.
startFieldIndex - Number.
It specifies from which field to start searching when more than one fields have been specified in fields.
wrap - Boolean.
If it is true, when there is no matching row after searching from startRow, it will search again from the first row to the prior row of startRow.
select - Boolean.
If found the matching cell, it will select this cell and scroll to display in grid.
Table-1  Search Cell Result
PropertyExplanation
rowIndexRow number of the searched cell.
fieldIndexField index of the searched cell.
fieldNameField name of the searched cell.
searchFieldIndexLocation of field which has been searched among the list of fields.
Table-2  Search Cell Options
PropertyDefault ValueExplanation
caseSensitivefalseIf it is true, it will be case sensitive.
partialMatchfalseIf it is true and the value is contained as partial field value, it will be considered as correct.
Code -1
    var prevRow = -1;
    var prevField = -1;
    
    $('#search').click(function () {
        var val = $('#cond').val();
        var options = { partialMatch: true };
        var result = grid.searchCell(['name', 'addr'], val, options, prevRow + 1, prevField + 1, true, true);
        if (result) {
            prevRow = result.rowIndex;
            prevField = result.searchFieldIndex;
        }
    });
See Also
searchRow
Examples
Search Row
Tree Search Row