This is a migrated thread and some comments may be shown as answers.

Control Panebar expand collapse from select event

2 Answers 286 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Coty
Top achievements
Rank 1
Coty asked on 17 Feb 2016, 02:12 AM

Hey there, I have a panel bar that can have multiple items.  I use the select method to do a bunch of code work.  I know want to implement an unsaved changes warning on the page so I need to implement a way to stop the panelbar from expanding or collapsing.

I know I can do it from the expand and collapse events - I have tested this and it works great (e.preventDefault()).  However since I have all of my coding within the select event and I have other actions that sometimes expand and collapse the panels dynamically I would like the ability to stop the panelbar from expanding and collapsing from the select event.  Is that possible?  I do see that the select event fires first.

Thanks,

 Coty

2 Answers, 1 is accepted

Sort by
0
Coty
Top achievements
Rank 1
answered on 18 Feb 2016, 01:53 AM

I created a work around for this - but I was hoping there was a better way instead of tracking a variable.  I figured I could set a variable flag on select, since the expand and collapse events occur after the select method.

Let me know if anyone has a better way?

$("#panelbar").kendoPanelBar({
    select: function (e) {
        if (expand) {
            console.log("set expand false");
            expand = false;
        } else {
            expand = true;
            console.log("set expand true");
        }
    },
    collapse: function (e) {
        console.log("collapse, expand=", expand);
        if (!expand) { e.preventDefault();}
    },
    expand: function (e) {
        console.log("expand, expand=", expand);
        if (!expand) { e.preventDefault(); }
    },
    expandMode: "multiple"
});

0
Kiril Nikolov
Telerik team
answered on 19 Feb 2016, 08:33 AM
Hi Coty,

I am afraid that there is no initial state that can be used for tracking the state of the widget, so a variable needs to be used if you want to keep track on the state. With that said your solution is a viable one.

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
PanelBar
Asked by
Coty
Top achievements
Rank 1
Answers by
Coty
Top achievements
Rank 1
Kiril Nikolov
Telerik team
Share this question
or