0
votes

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.

1

1 Answers

1
votes

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);