-
14 Feb 2013 10:24 AM #1
Using persistenceProperty breaks Grid in 4.2.0.489 RC
Using persistenceProperty breaks Grid in 4.2.0.489 RC
I tried using the persistenceProperty option in Ext.data.Model, and when I do, the Grid Panel stops displaying data.
I traced the problem back to Ext.view.Table in the renderCell function, fieldValue is obtained by:
fieldValue = record.data[column.dataIndex]
when it should use:
fieldValue = record.get(column.dataIndex)
Also, in Ext.grid.column.Template, defaultRenderer:
var data = Ext.apply({}, record.data, record.getAssociatedData());
should be:
var data = record.getData(true);
Changing this fixes the problem. I have not looked at what other classes use the same way of accessing the data, there may be others.
This also opens the door to the Grid Panel supporting nested keys in dataIndex, if the Ext.data.Model get function is replaced with:
This is very neat since now I can display data that forms part of a hasOne association within a grid, for example:Code:get: function(field) { if (!field) { return null; } var numKeys = field.indexOf('.'), record = this, keys, key, i, association; if (numKeys < 0) { //Non-nested key return this[this.persistenceProperty][field]; } else { //Nested key keys = field.split('.'); for (i in keys) { key = keys[i]; association = record.associations.get(key); if (association) { record = record[association.instanceName]; if (!record) { return null; } } else { return record.get(key); } } } },
I think it would also make sense to have Ext.data.Model.set support nested keys.Code:Ext.create('Ext.grid.Panel', { renderTo: Ext.getBody(), height: 250, columns: [ {dataIndex: 'firstName', flex: 1, header: 'First Name'}, {dataIndex: 'lastName', flex: 1, header: 'Last Name'}, //Column displays data from a hasOne association: {dataIndex: 'primaryAddress.address1', flex: 1, header: 'Address'} ] });
Let me know any comments,
Omar
-
14 Feb 2013 9:11 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
Thanks for the report.
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.
-
15 Feb 2013 12:04 AM #3Sencha - Community Support Team
- Join Date
- Nov 2007
- Location
- Helsingborg, Sweden
- Posts
- 2,455
- Vote Rating
- 52
Curious, what's the use case of using 'persistenceProperty'?
-
15 Feb 2013 1:21 AM #4
Not a lot, TBH I'm not sure why it was implemented in the first place.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
15 Feb 2013 1:24 AM #5Sencha - Community Support Team
- Join Date
- Nov 2007
- Location
- Helsingborg, Sweden
- Posts
- 2,455
- Vote Rating
- 52
Maybe having one more layer of abstraction added to Ext.data.Model would be great?

Code:persistencePropertyProperty : 'persistenceProperty'
-
15 Feb 2013 2:15 AM #6
Or maybe
For good measure? ;PCode:config: { persistencePropertyProperty: 'persistenceProperty' }Don Griffin
Ext JS Development Team Lead
Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue
"Use the source, Luke!"
-
15 Feb 2013 11:16 AM #7
I agree, I don't see much use to the option, however any class other than Ext.data.Model shouldn't really access the data object directly should they? Especially if we have the get and getData methods in Ext.data.Model.
-
15 Feb 2013 12:27 PM #8
The problem is one of performance really - for 4.2 we revamped the entire grid rendering pipeline to make the scrolling experience as smooth as possible. I suspect this is why this may have changed, but we do need to get away from this config because it presents some serious performance problems in data and its consumers.
So apologies for any hassle there.Don Griffin
Ext JS Development Team Lead
Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue
"Use the source, Luke!"
Success! Looks like we've fixed this one. According to our records the fix was applied for
EXTJSIV-8672
in
4.2.0 Sprint 4 (GA).


Reply With Quote