Javascript 用数据源过滤实现KendoUI网格搜索
我不确定我是否做得正确,但我想根据一个输入值筛选(“搜索”)剑道ui网格。但是,我想只基于一个输入搜索网格的两个字段Javascript 用数据源过滤实现KendoUI网格搜索,javascript,html,kendo-ui,kendo-grid,Javascript,Html,Kendo Ui,Kendo Grid,我不确定我是否做得正确,但我想根据一个输入值筛选(“搜索”)剑道ui网格。但是,我想只基于一个输入搜索网格的两个字段 $("#grid").data("kendoGrid").dataSource.filter({ logic: 'or', filters: [ { field: 'lastName', operator: 'startswith' }, { logic: 'or',
$("#grid").data("kendoGrid").dataSource.filter({
logic: 'or',
filters: [
{ field: 'lastName', operator: 'startswith' },
{
logic: 'or',
filters: [
{ field: 'lastName', operator: 'startswith', value: viewModel.searchValue },
{ field: 'address', operator: 'startswith', value: viewModel.searchValue }
]
}
]
});
html:
两个问题,如何实现这一点,以及如何触发过滤?现在,输入值仅绑定到viewModel的属性。要启用绑定值更新过滤器,请将其更改为:
viewModel.get('searchValue')
完整代码:
$("#grid").data("kendoGrid").dataSource.filter({
logic: 'or',
filters: [
{ field: 'lastName', operator: 'startswith' },
{
logic: 'or',
filters: [
{ field: 'lastName', operator: 'startswith', value: viewModel.get('searchValue') },
{ field: 'address', operator: 'startswith', value: viewModel.get('searchValue') }
]
}
]
});
$("#grid").data("kendoGrid").dataSource.filter({
logic: 'or',
filters: [
{ field: 'lastName', operator: 'startswith' },
{
logic: 'or',
filters: [
{ field: 'lastName', operator: 'startswith', value: viewModel.get('searchValue') },
{ field: 'address', operator: 'startswith', value: viewModel.get('searchValue') }
]
}
]
});