bassguy007
bassguy007

Reputation: 155

KendoUI PanelBar: unselect item on collapse

How do I automatically unselect a PanelBar item when it is collapsed? I'm using 2013.3.1119, and creating the PanelBar from JavaScript.

I found this thread from 2009, and tried plugging it in, but the parameters didn't match and it didn't work for me. I looked in the API Reference to wire up the collapse event handler, and put them together like this:

<script type="text/javascript">

    var panelBar;

    var onCollapse = function (e) {
        // access the collapsed item via e.item (HTMLElement)

        if (!e) { console.log('Error - e is ' + e); return; }
        if (!e.item) { console.log('Error - e.item is ' + e.item); return; }
        if (!e.item.unSelect) { console.log('Error - e.item.unSelect is ' + e.item.unSelect); return; }
        e.item.unSelect();
    };

    $(document).ready(function () {
        panelBar = $("#bids").kendoPanelBar({
            collapse: onCollapse
        });
    });

</script>

But this still doesn't work, it says e.item.unSelect is undefined. I've looked on both e.item and the panelBar object, and can't find any method that appears related to unselecting. How do I do this? Is it still supported? Thanks

Upvotes: 1

Views: 1699

Answers (1)

OnaBai
OnaBai

Reputation: 40897

Define your onCollapse as:

function onCollapse(e) {
     $(".k-state-selected", e.item).removeClass("k-state-selected k-state-focused");
}

Example here: http://jsfiddle.net/OnaBai/htmFG/

Upvotes: 4

Related Questions