I have a kendo grid displaying data correctly. I want to add an input box where when user types something in the grid filters that data, like a search box functionality for the grid.
Initially i set the grid's data source:
$("#grid").data("kendoGrid").setDataSource(new kendo.data.DataSource({ data: result }));
filter is applied like this:
$("#grid").data("kendoGrid").dataSource.filter({
logic: 'or',
filters: [
{ field: 'lastName', operator: 'startswith', value: viewModel.get('searchValue') },
{ field: 'address', operator: 'startswith', value: viewModel.get('searchValue') }
]
});
and the input box:
<input data-bind="value: searchValue" />
However whenever the searchValue
is changed, the dataSource remains the same, and the grid doesn't change.
Onchange function you may hookup below code
var kgrid = $("#grid").data("kendoGrid");
var orfilter = { logic: "or", filters: [] };
orfilter.filters.push({ field: "lastName", operator: "startswith", value: viewModel.get('searchValue') },
{ field: "address", operator: "startswith", value: viewModel.get('searchValue') });
kgrid.dataSource.filter(orfilter);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.