how can I filter Grid filtering based on values we entered in text box.
I have one text box out side the grid and i want to search the whole grid based on the values i entered in textbox. step1:
<input id="btnSearch" type="button" value="search" />
<div id="grid">
step2:bing grid value from source
var gridResult = $("#grid").kendoGrid({
dataSource: { data: database },
scrollable: true,
sortable: true,
filterable: true,
pageable: {
input: true,
numeric: false
},
columns: [
{
field: "id",
title: "ID"
},
{
field: "x",
title: "x"
},
{
field: "y"
},
{
field: "z"
},
{
field: "p"
}
]
});
step3: script for text box .that is wat ever the values i have typed in text box if the values match in grid the result should show in grid.
$("#btnSearch").click(function () {
$filter = new Array();
$x = $("#txtSearch").val();
if ($x) {
$filter.push({ field:"x", operator:"contains", value:$x});
}
gridResult.datasource.filter($filter);
});
To add a search box into a kendo grid we need to add Toolbar and search properties while initializing the kendo grid. Fields is an array of each field defined for the kendo grid. From the above snippet, the search will be applied for the name and age field of the grid.
Solution. On the dataBound event of the grid, find the filter dropdown and select() the desired default filter option. On the filter event of the Grid, if the filter is cleared, select the desired default filter option.
kendo:grid-pageable-messagesThe text messages displayed in pager. Use this option to customize or localize the pager messages.
Where you have:
gridResult.datasource.filter($filter);
it should read:
gridResult.data("kendoGrid").dataSource.filter($filter);
data("kendoGrid")
either here or when you declare var gridResult
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With