开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 3889|回复: 0

Kendo UI ListView选择功能

[复制链接]

0

精华

8

贡献

1768

赞扬

特约版主

帖子
583
软币
4524
在线时间
275 小时
注册时间
2019-2-21
发表于 2020-10-30 09:37:11 | 显示全部楼层 |阅读模式
Kendo UI目前最新提供Kendo UI for jQueryKendo UI for AngularKendo UI Support for ReactKendo UI Support for Vue四个控件。Kendo UI for jQuery是创建现代Web应用程序的最完整UI库。
默认情况下,ListView的选择功能处于禁用状态。
入门指南
ListView通过将selectable属性设置为“ single”或“ multiple”来支持项目选择功能。
[JavaScript] 纯文本查看 复制代码
$("#listView").kendoListView({
dataSource: dataSource,
selectable: "multiple",
template: kendo.template($("#template").html())
});

高级配置
您还可以检测用户何时通过更改事件获得项目,该事件是通过使用Shift + select组合选择一个或多个项目时触发的。
[JavaScript] 纯文本查看 复制代码
$("#listView").kendoListView({
change: function(e) {
var data = dataSource.view();
var selected = $.map(this.select(), function(item) {
return data[$(item).index()].ProductName;
});

// Index selected or read item information through data.
}
});

下面的示例演示了建议方法的完整实现。
[JavaScript] 纯文本查看 复制代码
<div id="listView" style="max-height:400px;overflow:auto;"></div>
<div class="k-pager-wrap">
<div id="pager"></div>
</div>

<script type="text/x-kendo-tmpl" id="template">
<div class="product">
<img src="https://demos.telerik.com/kendo-ui/content/web/foods/#= ProductID #.jpg" alt="#: ProductName # image" />
<h3>#:ProductName#</h3>
<p>#:kendo.toString(UnitPrice, "c")#</p>
</div>
</script>

<script>
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "https://demos.telerik.com/kendo-ui/service/Products",
dataType: "jsonp"
}
},
pageSize: 3
});

$("#pager").kendoPager({
dataSource: dataSource
});

$("#listView").kendoListView({
selectable: true,
dataSource: dataSource,
template: kendo.template($("#template").html())
});
</script>

<style>
.alt { background-color: #EEE; }
</style>



回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-4-27 12:42

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表