0
votes

I would like to disable some items in the kendo ListBox. There is a Sample in the kendo docs to disable: http://docs.telerik.com/kendo-ui/api/javascript/ui/listbox#methods-enable

But I would like disable some items in the list like:

var data = [
{ 'ProductID':'1', 'ProductName': 'Spalte 1', 'Discontinued': true, 'disabled': true },
{ 'ProductID':'2', 'ProductName': 'Spalte 2', 'Discontinued': true, 'disabled': false},
];

My full sample code: http://dojo.telerik.com/iKOmo/10

My goal is, disable items in the listBox when disabled = true is in the data object.

Thanks for some help Severin

1
Thanks for answer, i see this also and tested them. But it doesn't works for the ListBox. - Severin
For those who want to know how to disable all items: var listBox = $("#listBox").data("kendoListBox"); listBox.enable(".k-item", false); - JS5

1 Answers

0
votes

One solution for this Problem is:

$("#disable").click(function () {
  //console.log("my object: %o", opt_kendoListBox);       
  //alert(JSON.stringify(opt_kendoListBox.options.dataSource._data));
  for (i = 0; opt_kendoListBox.options.dataSource._data.length > i; i++) {
    if(opt_kendoListBox.options.dataSource._data[i].disabled){
      opt_kendoListBox.enable($(".k-item").eq(i),  false); 
    }
  }
});

It works correct only after initialization of listBox. A sample code: http://dojo.telerik.com/iKOmo/24 Not a perfect solution, but a helping solution i hope so.