PDA

View Full Version : accordin rendering



rkim
17 Jan 2012, 11:19 AM
I am saving last open accordion tab into cookie, and expand when page load
as below.

The second accordion expands fine, but first item cannot be opened anymore. If you remove the expand code, accordion works fine.
Is there any method that opens accordion item other than expand ? or is it a bug ?

listeners:
{
"afterrender":function()
{
var activeItem = Ext.getCmp("accordion_2"); //the last expanded item
if (activeItem)
activeItem.expand();
}
}




Ext.onReady(function()
{


var myBorderPanel = Ext.create("Ext.container.Viewport",
{
layout: "border",
margin:"0 0 0 0",
defaults:{border:false,header:false,defaults:{border:false}},
items: [
{
id:"westPanel",
region: "west",
collapsible: true,
collapseMode : "mini",
split: true, // enable resizing
layout:"fit",
width:250,
items:[
{
xtype:"panel",
layout:"accordion",
animate:false,
items:[
{
id:"accordion_1",
title:"accordion1"
},
{
id:"accordion_2",
title:"accordion2"
},
{
id:"accordion_3",
title:"accordion3"
}
]
}],
listeners:
{
"afterrender":function()
{
var activeItem = Ext.getCmp("accordion_2"); //the last expanded item
if (activeItem)
activeItem.expand();
}
}
},
{
id:"centerPanel",
region: "center", // center region is required, no width/height specified
margins: "0 5 0 0",
layout:"border",
autoScroll:false,
items:[]
}]
});


});

mitchellsimoens
17 Jan 2012, 11:26 AM
Instead of doing an expand in the afterrender event, why not just set collapsed : false on the item you want expanded?

rkim
17 Jan 2012, 11:35 AM
I have hardcoded accordion_2 to show you the bug, but value is actually from cookie
activeItem = Ext.getCmp(Ext.util.Cookies.get("accordioncookie"));

I don't know this is correct way or not.. but I changed it to below..
and still doesn't work.

activeItem.set("collapsed",false);
activeItem.setConfig("collapsed",false);