Function which can be used to customize filtering with local data (javascript sourced data).
The default filtering is not case sensitive. The filtering with remote data sources needs to be handled on the server.
Parameters
Name | Type | Description |
---|---|---|
value | {string} | the record field value |
searchStr | {string} | the search string |
Examples
example
<input type="text" id="txtValue1" placeholder="Value 1" />
<input type="text" id="txtValue2" placeholder="Value 2" />
<button id="btnSearch">Search</button> <br/><br/>
<table id="grid"></table>
<script>
var grid, data = [
{ 'ID': 1, 'Value1': 'Foo', 'Value2': 'Foo' },
{ 'ID': 2, 'Value1': 'bar', 'Value2': 'bar' },
{ 'ID': 3, 'Value1': 'moo', 'Value2': 'moo' },
{ 'ID': 4, 'Value1': null, 'Value2': undefined }
],
caseSensitiveFilter = function (value, searchStr) {
return value.indexOf(searchStr) > -1;
};
grid = $('#grid').grid({
dataSource: data,
columns: [
{ field: 'ID', width: 56 },
{ field: 'Value1' },
{ field: 'Value2', filter: caseSensitiveFilter }
]
});
$('#btnSearch').on('click', function () {
grid.reload({ Value1: $('#txtValue1').val(), Value2: $('#txtValue2').val() });
});
</script>