简体   繁体   English

通过jQuery在剑道列表视图中选择项目

[英]select items in kendo list view via jQuery

I have a kendo list view to display candidate information, I need to select candidate items in the list view on data bound event based on a Boolean property "IsPerfectMatch" in the data item. 我有一个Kendo列表视图来显示候选信息,我需要根据数据项中的布尔属性“ IsPerfectMatch”在数据绑定事件的列表视图中选择候选项。 The code is as below: 代码如下:

function onDataBound(){
var lisView = this;
$.each($("#dupCheckList").data("kendoListView").dataSource.data(),
          function(index, item){
                      if(item.IsPerfectMatch){
                          listView.select(this);
                       }
        });
}

When I debugged, I can see things working until the if block that checks "item.IsPerfectMatch" but the line of code "listView.select(this);" 调试后,我可以看到一切正常,直到if块检查“ item.IsPerfectMatch”,但代码行“ listView.select(this);”为止。 is not selecting the list item. 没有选择列表项。

Please suggest where could I be going wrong. 请提出我可能要去哪里的问题。

Also, I have set the list view selection mode to multiple for this list view. 另外,我已经为此列表视图将列表视图选择模式设置为多个。 I would want to disallow selection of only the first item in the list. 我想禁止仅选择列表中的第一项。 In other words, apart from the first item in the list view, all other items are selectable. 换句话说,除了列表视图中的第一项之外,其他所有项都是可选的。 Please suggest with sample jQuery code on how to achieve it. 请通过示例jQuery代码建议如何实现。

Thanks and regards, Damodar 感谢和问候,Damodar

ListView items are NOT the DataSource entries, so the value you're sending to the select() method is invalid. ListView项不是 DataSource条目,因此您发送给select()方法的值无效。 To iterate over the viewable children you will have to use the element.children() call. 要遍历可见的子代,您将必须使用element.children()调用。

var listView = this;
$.each(this.element.children(), function(index, item) {
    if (listView.dataSource.getByUid(item.dataset.uid).IsPerfectMatch) {
        listView.select(item);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM