Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: record.set not updating grid.

  1. #1
    Sencha User
    Join Date
    May 2010
    Posts
    177
    Vote Rating
    2
      0  

    Default record.set not updating grid.

    I have a form bound to a grid when I click on a record the data is displayed in the form. and the record can be edited. when I submit an edit I use the following in my controller:

    Code:
        form = Ext.getCmp('contentForm').getForm();
            record = form.getRecord(),
            values = form.getValues();
     if(values.contentID){
        record.set(values);
        Ext.getCmp('contentList').store.sync();
        //Ext.getCmp('contentList').store.commitChanges();
        } else{
         Ext.getCmp('contentList').store.add(values);
         Ext.getCmp('contentList').store.sync();
         Ext.getCmp('contentList').store.load();
        }
    on an edit I shouldn't have to load the store again but record.set is not updating the record in the grid. If I load the store again I can see the changes, if I click on the record I can see the the data displayed in the form is the new edited data. But the record in the grid continues to display the data as it was before the edit. unless I load the store again.

    I'm expecting record.set() to update the record in the grid. It should also show the record as dirty until I call store.commitChanges(); But that's not what I'm seeing.

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Vote Rating
    1272
      0  

    Default

    Is the store's datachanged event firing? The grid should be listening to the datachanged event on the store to change it's rows.
    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 User
    Join Date
    Mar 2011
    Posts
    208
    Vote Rating
    0
      0  

    Default

    Can you please elaborate more ?

  4. #4
    Sencha User
    Join Date
    May 2010
    Posts
    177
    Vote Rating
    2
      0  

    Default

    Sorry this is part of a large project and I havent had time to isolate the problem and create an example. In my large application though the datachanged event does not appear to fire.

  5. #5
    Sencha Premium Member
    Join Date
    Jan 2012
    Posts
    4
    Vote Rating
    0
      0  

    Default

    Dmoney's description is accurate, the record.set(values) command is not refreshing the grid although the store is correctly updated. If the user selects the row again from the grid or sorts from the column header, the modified field is marked as dirty. This code was working correctly in 4.0.7 but when I upgraded to 4.1 beta2, the problem appeared. I'm guessing the store's datachanged event isn't firing... any suggestions on a quick fix ???

    Controller:

    Ext.define('AM.controller.Users', {
    extend: 'Ext.app.Controller',


    views: [ 'user.List',
    'user.Edit'
    ],


    stores: [ 'Users' ],
    models: [ 'User' ],


    init: function() {
    this.control({
    'userlist': {
    itemdblclick: this.editUser
    },
    'useredit button[action=save]': {
    click: this.updateUser
    }
    });
    },


    editUser: function(grid, record) {
    var view = Ext.widget('useredit');
    view.down('form').loadRecord(record);
    },
    updateUser: function(button) {
    var win = button.up('window'),
    form = win.down('form'),
    record = form.getRecord(),
    values = form.getValues();
    record.set(values);
    win.close();
    this.getUsersStore().sync();


    }


    });

  6. #6
    Ext JS Premium Member burnnat's Avatar
    Join Date
    Jun 2011
    Posts
    418
    Vote Rating
    64
      0  

    Default

    Just a thought... perhaps this is related to EXTJSIV-5136?

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

    Default

    Can you produce a simple test case? Since this only involves a grid and a store it should be trivial

  8. #8
    Ext JS Premium Member burnnat's Avatar
    Join Date
    Jun 2011
    Posts
    418
    Vote Rating
    64
      0  

    Default

    Here's a test case I worked up. There are two buttons on the grid; they both increment the age of "Lisa", but the "Single Param" button uses the single-argument format for record.set(), while the "Double Param" uses the two-argument format. If you click them, you'll note that the "Double Param" button updates the value in the grid, but the "Single Param" does not.

    Code:
    Ext.onReady(function() {
        var store = Ext.create('Ext.data.Store', {
            fields:['name', 'email', 'phone', 'age'],
            data:{
                'items':[
                    { name: 'Lisa',  email: "lisa@simpsons.com",  phone: "555-111-1224", age: 14 },
                    { name: 'Bart',  email: "bart@simpsons.com",  phone: "555-222-1234", age: 16 },
                    { name: 'Homer', email: "home@simpsons.com",  phone: "555-222-1244", age: 42 },
                    { name: 'Marge', email: "marge@simpsons.com", phone: "555-222-1254", age: 38 }
                ]
            },
            proxy: {
                type: 'memory',
                reader: {
                    type: 'json',
                    root: 'items'
                }
            }
        });
        
        Ext.create('Ext.grid.Panel', {
            title: 'Simpsons',
            tbar: [{
                text: 'Single Param',
                handler: function() {
                    var rec = store.first();
                    rec.set({
                        age: rec.get('age') + 1
                    });
                }
            }, {
                text: 'Double Param',
                handler: function() {
                    var rec = store.first();
                    rec.set('age', rec.get('age') + 1);
                }
            }],
            store: store,
            columns: [
                { header: 'Name',  dataIndex: 'name', flex: 1 },
                { header: 'Email', dataIndex: 'email', flex: 1 },
                { header: 'Phone', dataIndex: 'phone', flex: 1 },
                { header: 'Age', dataIndex: 'age', flex: 1 }
            ],
            height: 200,
            width: 500,
            renderTo: Ext.getBody()
        });
    });

  9. #9
    Sencha Premium User powellke's Avatar
    Join Date
    Sep 2008
    Location
    Huntsville, AL
    Posts
    38
    Vote Rating
    5
      0  

    Default

    This problem still exists in version 4.2.0.663. I have confirmed that the datachanged event is not getting fired when I call set with a new value.

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

    Default

    @ powellke: Can you please provide a fresh test case to use with Ext 4.2?

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

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