我有一个绑定到数据源的剑道列表视图。当用户单击我调用的添加按钮时$("#arealistview").data("kendoMobileListView").prepend([newItem])
,它将一个新项目添加到列表的开头。
如何获取列表视图中项目的计数?
我有一个绑定到数据源的剑道列表视图。当用户单击我调用的添加按钮时$("#arealistview").data("kendoMobileListView").prepend([newItem])
,它将一个新项目添加到列表的开头。
如何获取列表视图中项目的计数?
我相信你应该能够做到
var numItems=$("#arealistview").data("kendoMobileListView").length;
您可以随时参考这里http ://docs.kendoui.com/api/web/listview 如果这仍然没有产生任何结果,我建议与 Kendo 代表联系,他们是非常乐于助人的人。
<!DOCTYPE html>
<html>
<head>
<base href="https://demos.telerik.com/kendo-ui/treeview/dragdrop">
<style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</style>
<title></title>
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2019.1.115/styles/kendo.common-material.min.css" />
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2019.1.115/styles/kendo.material.min.css" />
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2019.1.115/styles/kendo.material.mobile.min.css" />
<script src="https://kendo.cdn.telerik.com/2019.1.115/js/jquery.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2019.1.115/js/kendo.all.min.js"></script>
</head>
<body>
<div id="example">
<div class="demo-section k-content">
<h4>Treeview One</h4>
<div id="treeview-left"></div>
</div>
<script id="treeview-template" type="text/kendo-ui-template">
#= item.text # <span class='item-count'></span>
</script>
<script>
$("#treeview-left").kendoTreeView({
template: kendo.template($("#treeview-template").html()),
dataSource: [
{ text: "Furniture", expanded: true, items: [
{ text: "Tables & Chairs" },
{ text: "Sofas" },
{ text: "Occasional Furniture" }
] },
{ text: "Decor", items: [
{ text: "Bed Linen" },
{ text: "Curtains & Blinds" },
{ text: "Carpets" }
] }
],
dataBound: function(e) {
var item = this.dataItem(e.node);
var children = item && item.children ? item.children.data().length : undefined;
var text = children ? ("(" + children + ")") : "";
$(e.node).find(">div .item-count").text(text);
}
});
$("#treeview-right").kendoTreeView({
dragAndDrop: true,
dataSource: [
{ text: "Storage", expanded: true, items: [
{ text: "Wall Shelving" },
{ text: "Floor Shelving" },
{ text: "Kids Storage" }
]
},
{ text: "Lights", items: [
{ text: "Ceiling" },
{ text: "Table" },
{ text: "Floor" }
]
}
]
});
</script>
<style>
#treeview-left,
#treeview-right
{
overflow: visible;
}
</style>
</div>
</body>
</html>
这是用于树视图