数据管理必看!Kendo UI for jQuery过滤器状态保持
Kendo UI目前最新提供Kendo UI for jQuery、Kendo UI for Angular、Kendo UI Support for React和Kendo UI Support for Vue四个控件。Kendo UI for jQuery是创建现代Web应用程序的最完整UI库。
Kendo UI Filter小部件是一个统一的控件,用于筛选具有数据源的数据绑定组件。
使用Kendo UI for jQuery的过滤器,您可以存储其过滤器表达式并为用户恢复其状态。
恢复负载状态
例如,您只能存储过滤器表达式,并使过滤器能够在用户下次访问页面时应用它。
下面的示例演示如何使用change事件自动应用过滤并保持Filter的最新状态。 重新加载页面后,存储的设置将提供给过滤器配置并应用。
<ol><li>Change the filter.</li><li>Reload the page: <button type="button" onclick="reloadPage();">Reload</button></li><li>The widget will be initialized with the settings that were stored.</li><li>Clear the stored information to start fresh: <button onclick="clearData();">Clear</button></li></ol><div id="filter"></div><ul id="listView"></ul>
<script type="text/x-kendo-template" id="item">
<li>
<strong>#= name #</strong>, aged #= age #, is on vacation: #= isOnLeave #
</li>
</script>
<script>
$(document).ready(function () {
var dataSource = new kendo.data.DataSource({
data: [
{ name: "Jane Doe", age: "25", isOnLeave: false },
{ name: "John Doe", age: "33", isOnLeave: true },
{ name: "John Smith", age: "37", isOnLeave: true },
{ name: "Nathan Doe", age: 42, isOnLeave: false }
],
schema: {
model: {
fields: {
name: { type: "string" },
age: { type: "number" },
isOnLeave: { type: "boolean" }
}
}
}
});
$("#filter").kendoFilter({
dataSource: dataSource,
change: applyAndStoreFilterExpression,
expressionPreview: true,
fields: [
{ name: "name", type: "string", label: "Name" },
{ name: "age", type: "number", label: "Age" },
{ name: "isOnLeave", type: "boolean", label: "On Vacation" }
],
expression: getInitialExpression()
}).data("kendoFilter");
if (getInitialExpression()) { // Apply filter if there was a stored expression.
$("#filter").data("kendoFilter").applyFilter();
}
$("#listView").kendoListView({
dataSource: dataSource,
template: kendo.template($("#item").html())
});
});
function applyAndStoreFilterExpression(e) {
e.sender.applyFilter(); // Apply filtering on every change.
localStorage["myInitialFilterExpression"] = JSON.stringify(e.expression); // Store the filter expression for future use.
}
function getInitialExpression() {
if (localStorage["myInitialFilterExpression"]) {
return JSON.parse(localStorage["myInitialFilterExpression"]);
}
}
function reloadPage() {
window.location.reload();
}
function clearData() {
delete localStorage["myInitialFilterExpression"];
reloadPage();
}
</script>
按需加载设置
您还可以在发生应用程序逻辑事件时保存并加载筛选器的先前特定状态。
下面的示例演示如何获取当前的过滤器表达式和任何其他设置,并在需要时应用它们。
<ol><li>Change the state of the filter.</li><li>Save the state <button onclick="saveState();">Save</button></li><li>Change the state of the filter again.</li><li>Load the state: <button onclick="loadState();">Load</button></li><li>Clear the state: <button onclick="clearState();">Clear</button></li></ol>
<div id="filter"></div>
<div id="chart"></div>
<script>
$(document).ready(function () {
var dataSource = new kendo.data.DataSource({
data: [
{ price: 25, year: 2017 },
{ price: 29, year: 2018 },
{ price: 33, year: 2019 }
],
schema: {
model: {
fields: {
price: { type: "number" },
year: { type: "number" }
}
}
}
});
$("#filter").kendoFilter({
dataSource: dataSource,
expressionPreview: true,
applyButton: true,
fields: [
{ name: "price", type: "number", label: "Cost" },
{ name: "year", type: "number", label: "Year" }
]
}).data("kendoFilter");
$("#chart").kendoChart({
dataSource: dataSource,
series: [
{ field: "price" }
],
categoryAxis: {
field: "year"
}
});
});
function saveState(e) {
localStorage["myFilterSettings"] = JSON.stringify(getFilter().getOptions().expression);
// You can store and restore all options not just the expression.
}
function loadState() {
if (localStorage["myFilterSettings"]) {
var filter = getFilter();
var opts = filter.getOptions();
opts.expression = JSON.parse(localStorage["myFilterSettings"]);
filter.setOptions(opts);
// If you will restore all options, you need only filter.setOptions(myOptionsLiteral).
filter.applyFilter(); // Apply the new filter expression.
}
}
function clearState() {
delete localStorage["myFilterSettings"];
}
function getFilter() {
return $("#filter").data("kendoFilter");
}
</script>
了解最新Kendo UI最新资讯,请关注Telerik中文网!
扫描关注慧聚IT微信公众号,及时获取最新动态及最新资讯

数据管理必看!Kendo UI for jQuery过滤器状态保持的更多相关文章
- 数据管理必看!Kendo UI for jQuery过滤器的全球化
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
- 数据管理必看!Kendo UI for jQuery过滤器概述
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
- Web界面开发必看!Kendo UI for jQuery编辑功能指南第二弹
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
- Web界面开发必看!Kendo UI for jQuery编辑功能指南第一弹
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
- Web UI开发神器—Kendo UI for jQuery数据管理之过滤操作
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
- Web UI开发神器—Kendo UI for jQuery数据管理网格编辑操作
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
- Kendo UI for jQuery自定义小部件第一弹!不得不看的入门指南
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
- 不知如何摧毁Kendo UI for jQuery小部件?这份指南不得不看
[Kendo UI for jQuery最新试用版下载] Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support ...
- Web UI开发速速种草—Kendo UI for jQuery网格编辑操作概述
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
随机推荐
- java 重写的 几大注意点
Single Dispatch class Parent { void print(String a) { log.info("Parent - String"); } void ...
- Linux .bin安装的文件制作
setup.sh #! /bin/sh lines=8 #shell 脚本行数+,在这个例子中,setup.sh一共7行,则lines=8 > tmp.tar.gz tar -xvf tmp.t ...
- *【Python】【demo实验31】【练习实例】【使用turtle画小猪佩奇】
如下图小猪佩奇: 要求使用turtle画小猪佩奇: 源码: # encoding=utf-8 # -*- coding: UTF-8 -*- # 使用turtle画小猪佩奇 from turtle i ...
- 【java基础学习001】概述
001.1 一个简单的Java程序 public class hello { public static void main(String[] args) { System.out.printl ...
- selenium爬取斗鱼所有直播房间信息
还是分析一下大体的流程: 首先还是Chrome浏览器抓包分析元素,这是网址:https://www.douyu.com/directory/all 发现所有房间的信息都是保存在一个无序列表中的li中, ...
- 并不对劲的bzoj4001:loj2105:p3978:[TJOI2015]概率论
题目大意 随机生成一棵\(n\)(n\leq10^9)个节点的有根二叉树,问叶子结点个数的期望. 题解 subtask 1:\(n\leq100\),70pts 结论:不同的\(n\)个节点的有根二叉 ...
- .NET CORE API 使用Postman中Post请求获取不到传参问题
开发中遇到个坑 记录下. 使用Postman请求core api 接口时,按之前的使用方法(form-data , x-www-form-urlencoded)怎么设置都无法访问. 最后采用raw写入 ...
- 安装sshpass
sshpass: 用于非交互的ssh 密码验证 ssh登陆不能在命令行中指定密码,也不能以shell中随处可见的,sshpass 的出现,解决了这一问题.它允许你用 -p 参数指定明文密码,然后直接 ...
- 【js】面向对象学习资料
1.面向对象模式: https://m.jb51.net/article/74549.htm 2.面向对象基础篇 http://www.cnblogs.com/chiangchou/p/js-oop1 ...
- Kendall tau距离(即两个内容相同的数组中逆序数对的数量)(算法》P220 第2.5.3.2小节)
一组排列就是一组N个整数的数组,其中0~N-1的每个数都只出现一次.两个排列之间的 Kendall tau距离就是在两组排列中相对顺序不同的数对的数目.例如,0 3 1 6 2 5 4和1 0 3 6 ...