如何根据我们在文本框中输入的值过滤网格过滤.
我在网格旁边有一个文本框,我想根据我在文本框中输入的值搜索整个网格.步骤1:
<input id="btnSearch" type="button" value="search" />
<div id="grid">
Run Code Online (Sandbox Code Playgroud)
step2:从源代码中获取网格值
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"
}
]
});
Run Code Online (Sandbox Code Playgroud)
step3:文本框的脚本.如果值在网格中匹配,则我在文本框中键入的值,结果应显示在网格中.
$("#btnSearch").click(function () {
$filter = new Array();
$x = $("#txtSearch").val();
if ($x) {
$filter.push({ field:"x", operator:"contains", value:$x});
}
gridResult.datasource.filter($filter); …Run Code Online (Sandbox Code Playgroud) 将数据导出到Excel时如何更改文件名?
<div id="example" class="k-content">
<button type="button"id="btnExport">Export to csv!</button>
<div id="grid"></div>
</div>
<script>
$("#btnExport").click(function (e) {
var result = "data:application/vnd.ms-excel,";
window.open(result);
e.preventDefault();
});
</script>
Run Code Online (Sandbox Code Playgroud)
当我单击导出按钮时,我将获得download.xls.是否可以将文件名设置为data.xls?任何人都可以解释我需要配置的地方吗?