-
17 Jan 2012 11:19 AM #1
accordin rendering
accordin rendering
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();
}
}
Code: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:[] }] }); });
-
17 Jan 2012 11:26 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 436
Instead of doing an expand in the afterrender event, why not just set collapsed : false on the item you want expanded?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
17 Jan 2012 11:35 AM #3
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);


Reply With Quote