Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-8672 in 4.2.0.663.
  1. #1
    Ext JS Premium Member
    Join Date
    Jul 2008
    Location
    Miami, FL
    Posts
    56
    Vote Rating
    1
    omarc is on a distinguished road

      0  

    Default 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:

    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);
                    }
                }
            }
        },
    This is very neat since now I can display data that forms part of a hasOne association within a grid, for example:

    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'}
            ]
        });
    I think it would also make sense to have Ext.data.Model.set support nested keys.

    Let me know any comments,

    Omar

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,015
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thanks for the report.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    2,747
    Vote Rating
    106
    mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all

      0  

    Default


    Curious, what's the use case of using 'persistenceProperty'?

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,906
    Vote Rating
    626
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    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!

  5. #5
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    2,747
    Vote Rating
    106
    mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all

      0  

    Default


    Maybe having one more layer of abstraction added to Ext.data.Model would be great?

    Code:
    persistencePropertyProperty : 'persistenceProperty'

  6. #6
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,346
    Vote Rating
    134
    dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all

      0  

    Default


    Or maybe

    Code:
       config: {
           persistencePropertyProperty: 'persistenceProperty'
       }
    For good measure? ;P
    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!"

  7. #7
    Ext JS Premium Member
    Join Date
    Jul 2008
    Location
    Miami, FL
    Posts
    56
    Vote Rating
    1
    omarc is on a distinguished road

      0  

    Default


    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.

  8. #8
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,346
    Vote Rating
    134
    dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all

      0  

    Default


    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!"