PDA

View Full Version : List will broken after update



cedage
25 Jul 2011, 2:10 PM
Hello every one.

I need help.



Ext.regModel('ParentsModel', {
fields:['id', 'name', 'childs']
});

Ext.regModel('ChildsModel', {
fields:['id', 'parent_id', 'name', 'description']
});

var parentData = new Ext.data.Store({
model: 'ParentsModel',
data: [
{id: 1, name: 'Parent 1', childs: 13},
{id: 2, name: 'Parent 2', childs: 16},
{id: 3, name: 'Parent 3', childs: 8}
]
});

var ChildData = new Ext.data.Store({
model: 'ChildsModel',
data: [
{id: 1, parent_id: 1, name: 'Child 1', description: 'Lorem Ipsum...'},
{id: 2, parent_id: 1, name: 'Child 2', description: 'Lorem Ipsum...'},
{id: 3, parent_id: 1, name: 'Child 3', description: 'Lorem Ipsum...'},
{id: 4, parent_id: 2, name: 'Child 6', description: 'Lorem Ipsum...'},
{id: 5, parent_id: 2, name: 'Child 7', description: 'Lorem Ipsum...'},
{id: 6, parent_id: 2, name: 'Child 8', description: 'Lorem Ipsum...'},
{id: 7, parent_id: 3, name: 'Child 11', description: 'Lorem Ipsum...'},
{id: 8, parent_id: 3, name: 'Child 12', description: 'Lorem Ipsum...'},
{id: 9, parent_id: 3, name: 'Child 13', description: 'Lorem Ipsum...'}
]
});


/* Application */
APP = new Ext.Application({
name: 'APP',

launch: function(){

/* Childs List */
APP.ChildsList = new Ext.List({
id: 'ChildsList',
store: ChildData,
itemTpl: '{name}'
});

/* Childs Wraper */
APP.ChildsWraper = new Ext.Panel({
id: 'ChildsWraper',
layout:'fit',
dockedItems:[
{
xtype:'toolbar',
items:[
{
text:'back',
ui:'back',
handler: function(){
APP.Viewport.setActiveItem('ParentsList');
}
}
]
}
],
items:[APP.ChildsList]
});

/* Parents List */
APP.ParentsList = new Ext.NestedList({
id: 'ParentsList',
store: ParentData,
itemTpl: '{name}',
onItemDisclosure: function(record, btn, index){
APP.ChildsList.update();
APP.Viewport.setActiveItem('ChildsWraper');
}
});

/* Main Viewport */
APP.Viewport = new Ext.Panel({
fullscreen: true,
layout: 'card',
items:[APP.ParentsList, APP.ChildsWraper]
});
}
});


when I click on parent item firstly, I see in child list all items
and then go back to parent list and click on another parent item
after child list contain one item

please help

Thanks