Skip to content Skip to sidebar Skip to footer

How Can I Disable An Item In A Kendo ListView?

I'm trying to disable an item in my Kendo listview control. I've tried calling $('#itemid').prop('disabled', true); but it had no effect (it's a div, not an input). I don't want

Solution 1:

This isn't really supported by Kendo UI at the moment. The selection is cleared in the Selectable's _tap method. You can hack something together by overriding kendoSelectable's _tap method, e.g.:

kendo.ui.Selectable.fn._myTap = kendo.ui.Selectable.fn._tap;
kendo.ui.Selectable.fn._tap =  function(e) {
    if ($(e.target).hasClass("my-disabled-item")) {
        return;
    }

    this._myTap(e);
}

and adding a disableItem method to ListView:

kendo.ui.ListView.fn.disableItem =  function(elem) {
    $(elem).addClass("my-disabled-item");
}

See a demo which has the first two items disabled here: http://jsfiddle.net/lhoeppner/vP2L9/

Note that all of this might break with upgrades (there's no guarantee Telerik will keep this code in the _tap method).


Post a Comment for "How Can I Disable An Item In A Kendo ListView?"