Domanda

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. 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);" 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.

Thanks and regards, Damodar

È stato utile?

Soluzione

ListView items are NOT the DataSource entries, so the value you're sending to the select() method is invalid. To iterate over the viewable children you will have to use the element.children() call.

var listView = this;
$.each(this.element.children(), function(index, item) {
    if (listView.dataSource.getByUid(item.dataset.uid).IsPerfectMatch) {
        listView.select(item);
    }
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top