View Full Version : TreePanel with associated models just shows the main model

12 Nov 2011, 10:41 AM
i'm trying do display the data from 2 associated stores in a tree panel. But the problem is that the items from the second store aren't displayed. Here are the relevant code snippets

The main model, it can have several fragmants which should be displayed as subfolders.

Ext.define('app.model.Main', {
extend : 'Ext.data.Model',
fields : [{
name : 'id',
type : 'int'
}, {
name : 'text',
type : 'string'
hasMany : {
model : 'app.model.Fragment',
name : 'fragments',
autoload: true

Ext.define('app.store.Main', {
extend : 'Ext.data.TreeStore',
model: 'app.model.Main',
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'root'

root : {
expanded : true,
text : 'root'

The model for the fragments which aren't displayed

Ext.define('app.model.Fragment', {
extend: 'Ext.data.Model',
fields: ['id', 'main_id', 'text'],
belongsTo: 'app.model.Main'

In the view theres a button to add a new chapter. On a click the chapter is added and the fragment is added to the main model to but it's not displayed in the tree.

Ext.define('app.view.TreePanel', {
extend : 'Ext.tree.Panel',
alias : 'widget.treepanel',

store : 'StoreA',

displayField : 'text',

initComponent : function() {
this.dockedItems = [{
dock : 'top',
xtype : 'toolbar',
items : [{
xtype : 'button',
text : 'Add',
action : 'add'

Here is the part i add the new chapter to the model. First i create the fragment then a new chapter. Afterwards the fragment is added to the chapter and all together is appended to the selected node.

Ext.define('app.controller.Main', {
extend : 'Ext.app.Controller',
onAdd : function() {
var fragment = Ext.create('app.model.Fragment', {
id: 300,
main_id: this.count,
text: 'test'
var main = Ext.create('app.model.Main', {
id: this.count,
text : 'Chapter ' + this.count++,
var chaptersList = this.getChaptersList();
var selection = chaptersList.getSelectionModel().getSelection();

As i said the model seems to be working fine. All fragments are added to it's corresponding chapters, but they aren't displayed in the treepanel.
Am I missing something?

14 Nov 2011, 2:02 AM
What I know, this is not supported yet. You can only have one model for the tree client side.

14 Nov 2011, 4:04 PM
hmm ok,
i solved this no in the way that i add new text nodes to the tree and the rest of the data will be coverd by the other stores.. not the solution i expected but it works...