سؤال

I have a Kendo list view that displays list of candidates with list view selection mode set to multiple. 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

هل كانت مفيدة؟

المحلول

Try the following code :

 $("#listView div:first-child").toggleClass('k-selectable');

Hope this helps!

UPDATE :

In order to select the first item, you need to add the following code :

var listView = $("#listView").data("kendoListView");
listView.select(listView.element.children().first());

UPDATE2:

To keep the item selected irrespctive of what changes, handle the change event of the grid as follows :

change: function() {
      if(!(this.element.children().first().hasClass('k-state-selected')))
        {this.select(this.element.children().first());}      
    }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top