PDA

View Full Version : Nested Form Data with Different Models



rpsirois
6 Aug 2012, 10:46 AM
How can I accomplish nested form data with TreePanels? I feel as if this question has been asked a lot, but I can't seem to find a good solution.

The cheater sort of way I was attempting looks like this:


(tree panel)
beforeitemexpand: function( record, opts ) {
this.getStore().getProxy().extraParams.cmd = 'list_attributes';
this.getStore().getProxy().extraParams.categoryID = record.data.typeID;
this.getStore().getProxy().setModel( 'BIS.model.AttributeModel' );
},

I agree that that is a little ridiculous. The problem is when I want a different node (say, the parent node with a different model), I get undefined data.

I would think that using Model's #hasMany: / #belongsTo: properties would provide some functionality to this end?

The data does need to be loaded dynamically. Pre-loading the entire graph is not an option.

Thanks

scottmartin
24 Aug 2012, 9:16 PM
Here is a good example of loading nested data:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.reader.Reader

I must say I am a little confused on your intentions.

Scott.

rpsirois
27 Aug 2012, 7:14 AM
Thanks for the response.

My model is set up in the fashion of:



Ext.define('Namespace.model.ValueModel', {
extend: 'Ext.data.Model',
fields: [
{
name: 'title'
}
],
belongsTo: 'Namespace.model.KeyModel'
});



Ext.define('Namespace.model.KeyModel', {
extend: 'Ext.data.Model',
fields: [
{
name: 'title'
}
],
hasMany: 'Namespace.model.ValueModel'
});


My dataset is far too large to statically load, so my question is, how do I load children? Do I need to load the top level node and it's entire tree to get to the child?

Thanks,
RS