Results 1 to 8 of 8

Thread: Using persistenceProperty breaks Grid in 4.2.0.489 RC

    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
    72
    Vote Rating
    1
      0  

    Default 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 User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,029
    Vote Rating
    1367
      0  

    Default

    Thanks for the report.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha Premium User mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    3,137
    Vote Rating
    189
      0  

    Default

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

  4. #4
    Sencha User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,968
    Vote Rating
    931
      0  

    Default

    Not a lot, TBH I'm not sure why it was implemented in the first place.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  5. #5
    Sencha Premium User mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    3,137
    Vote Rating
    189
      0  

    Default

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

    Code:
    persistencePropertyProperty : 'persistenceProperty'

  6. #6
    Sencha User dongryphon's Avatar
    Join Date
    Jul 2009
    Location
    Kansas
    Posts
    1,740
    Vote Rating
    259
      0  

    Default

    Or maybe

    Code:
       config: {
           persistencePropertyProperty: 'persistenceProperty'
       }
    For good measure? ;P
    Don Griffin

    "Use the source, Luke!"

  7. #7
    Ext JS Premium Member
    Join Date
    Jul 2008
    Location
    Miami, FL
    Posts
    72
    Vote Rating
    1
      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 User dongryphon's Avatar
    Join Date
    Jul 2009
    Location
    Kansas
    Posts
    1,740
    Vote Rating
    259
      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

    "Use the source, Luke!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •