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

Blocking Panelbar Expansion

3 Answers 382 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 08 Mar 2012, 07:49 PM
I'm trying to block the expansion of a panel bar to no avail. I've tried both of these methods on the select and expand event:

function OnSelect(e) {
         e.preventDefault();
}


function OnExpand(e) {
        e.preventDefault();
}

I just really need a method to block the expansion if something fails, any suggestions or alternatives would be welcome.

3 Answers, 1 is accepted

Sort by
0
Guru
Top achievements
Rank 2
answered on 14 May 2012, 11:44 PM
Hi Josh, I am able to block expanding or collapsing in our apps by doing the following:

$('#PanelBar').kendoPanelBar({
   expand: function (e) {
      if (e.item.id == 'SpecificListItemID') e.preventDefault();
   }
});

I have tested this with success for both expand and collapse events.
0
Coty
Top achievements
Rank 1
answered on 18 Feb 2016, 01:50 AM

I actually had a similar question to this.  Zack is correct in that you can prevent the expand within the expand method of the panelbar by calling e.preventDefault().  

However, is there a way to disable the expand from the onSelect event?  I did a workaround with a flag variable but I was hoping there was 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
Petyo
Telerik team
answered on 23 Feb 2016, 09:36 AM
Hello Coty,

your approach seems correct. The select event does not support prevention, currently. 

Regards,
Petyo
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
Josh
Top achievements
Rank 1
Answers by
Guru
Top achievements
Rank 2
Coty
Top achievements
Rank 1
Petyo
Telerik team
Share this question
or