Control Panebar expand collapse from select event

3 posts, 0 answers
  1. Coty
    Coty avatar
    41 posts
    Member since:
    Jun 2014

    Posted 16 Feb Link to this post

    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. Coty
    Coty avatar
    41 posts
    Member since:
    Jun 2014

    Posted 17 Feb in reply to Coty Link to this post

    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"
    });

  3. Kendo UI is VS 2017 Ready
  4. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 19 Feb Link to this post

    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!
     
Back to Top