-
24 Nov 2011 8:11 AM #1
Answered: Load substore in a Grid
Answered: Load substore in a Grid
Hello
I have an association in my store, i want to load subdata in a grid.
My models
My gridCode:Ext.define('Zone', { extend: 'Ext.data.Model', fields: ['id', 'name'], hasMany : {model: 'RefItemZone', name: 'refItems', associationKey:'refItems'} }); Ext.define('RefItemZone', { extend: 'Ext.data.Model', fields: ['link'], belongsTo: 'Zone' });
Code:var grid = Ext.create('Ext.grid.Panel', { renderTo: document.body, plugins: [rowEditing], width: '100%', height: window.innerHeight, frame: true, title: 'Zones', store: store, collapsible: true, columns: [{ text: 'ID', width: 40, sortable: true, dataIndex: 'id' }, { text: 'Nom', flex: 1, sortable: true, dataIndex: 'name', field: { xtype: 'textfield' } },{ text: 'Component', flex: 1, sortable: true, dataIndex: 'SOMETHING THERE', field: { xtype: 'textfield' } }] });
Thank for your help
-
Best Answer Posted by flanders
There are some in the docs for Column and grid.Panel (http://docs.sencha.com/ext-js/4-0/#!....column.Column)
An other example:
render: function(value, metaData, record) {
return value + ' ' + record.get('anythingElse');
}
-
24 Nov 2011 8:36 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
You cannot have two different stores on a grid. The only thing that you can do is when the hasMany store has data, update the record on the main store but that's messy.
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.
-
24 Nov 2011 11:37 PM #3
Store
Store
Ok but i have only one store with sub store in it.
Code:var store = Ext.create('Ext.data.Store', { autoLoad: true, autoSync: true, sorters: 'id', groupField: 'name', model: 'Zone', proxy: { type: 'rest', url: '/rest/zones', reader: { type: 'json' }, writer: { type: 'json' } } });
Capture-1.png
-
25 Nov 2011 10:18 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
I see... you will need to use a renderer in that case. dataIndex should be the first level key in the record.data Object and then the renderer, the first argument will be the value of that key... you can then traverse down that and return what you want to be displayed. If you need something included in the record, the record is passed as the 3rd argument i believe.
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.
-
27 Nov 2011 1:31 AM #5
Ok Thanks !

Do you have an example of this ?
-
27 Nov 2011 5:30 AM #6Sencha User
- Join Date
- Dec 2009
- Location
- Enschede, The Netherlands
- Posts
- 327
- Vote Rating
- 11
- Answers
- 16
There are some in the docs for Column and grid.Panel (http://docs.sencha.com/ext-js/4-0/#!....column.Column)
An other example:
render: function(value, metaData, record) {
return value + ' ' + record.get('anythingElse');
}


Reply With Quote