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
    69
    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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    Thanks for the report.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha Premium User mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    3,078
    Vote Rating
    184
      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
    18,608
    Vote Rating
    874
      0  

    Default

    Not a lot, TBH I'm not sure why it was implemented in the first place.
    Evan Trimboli
    Twitter - @evantrimboli

  5. #5
    Sencha Premium User mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    3,078
    Vote Rating
    184
      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
    Location
    Kansas
    Posts
    1,727
    Vote Rating
    249
      0  

    Default

    Or maybe

    Code:
       config: {
           persistencePropertyProperty: 'persistenceProperty'
       }
    For good measure? ;P
    Don Griffin
    Director of Engineering - Frameworks (Ext JS / Sencha Touch)

    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
    69
    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 - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Location
    Kansas
    Posts
    1,727
    Vote Rating
    249
      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
    Director of Engineering - Frameworks (Ext JS / Sencha Touch)

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

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