【发布时间】:2012-12-07 05:18:52
【问题描述】:
如何根据我们在文本框中输入的值过滤网格过滤。
我在网格外有一个文本框,我想根据我在文本框中输入的值搜索整个网格。 第一步:
<input id="btnSearch" type="button" value="search" />
<div id="grid">
step2:bing 来自源的网格值
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"
}
]
});
第 3 步:文本框脚本。如果值在网格中匹配,那么我在文本框中输入的值将显示在网格中。
$("#btnSearch").click(function () {
$filter = new Array();
$x = $("#txtSearch").val();
if ($x) {
$filter.push({ field:"x", operator:"contains", value:$x});
}
gridResult.datasource.filter($filter);
});
【问题讨论】:
-
请详细一点。此外,请说明您正在努力实现的目标以及您在此过程中已经尝试过的目标。