1. #1
    Sencha User
    Join Date
    Mar 2009
    Posts
    84
    Answers
    1
    Vote Rating
    0
    Speedy is on a distinguished road

      0  

    Arrow Unanswered: change records using the set() method

    Unanswered: change records using the set() method


    Hi,


    I use a grid with a store that is manually loaded via ajax, that is why i use a memory store.
    Manually my grid has a method that shall change some values via script.


    Code:
    var store = Ext.create('Ext.data.Store', {
                fields: ['value', 'display', 'visible', 'isDefault' ], autoLoad: true,  
                data: [
                 { value: 'A', display: ' Display A', visible: false, isDefault: false },
                 { value: 'B', display: 'Display B' visible: false, isDefault: false },
                 { value: 'C', display: 'Display C', visible: false, isDefault: false }
                ],
                proxy: {
                    type: 'memory',
                    reader: { type: 'json', root: 'data', idProperty: 'value' }
                }
            });

    the method that shall edit the store is trying to do f.e.

    Code:
                var rec = grid.getStore().findRecord( 'value', 'A' );
                rec.set('isDefault', true);
    after this line of code the following error is thrown by firebug

    d is undefined
    d.parentNode.insertBefore(replacement, d); ext-debug.js( 16037 )


    I tried to debug and it looks like this error happens when the grid view wants to update the grid-rows somehow.

    Even more weird is, if I use
    Code:
          rec.data.isDefault = true;
    instead of the set method the error does not occur.


    Someone knows what is going wrong here?



    thanks,

    Speedy

  2. #2
    Sencha User skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,338
    Answers
    498
    Vote Rating
    248
    skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of

      0  

    Default


    Exact ExtJS version?

    Tried it in different browsers?

    Grid config?

  3. #3
    Sencha User
    Join Date
    Mar 2009
    Posts
    84
    Answers
    1
    Vote Rating
    0
    Speedy is on a distinguished road

      0  

    Default


    4.0.2a

    tried with Firefox 5 only

    the file extends the grid and the config is applied within the initComponent method


    Code:
            
    
    Ext.apply(this, {
                store: store, 
                plugins: [ Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }) ],
                selType: 'cellmodel', 
                columns: [{
                    name: 'display', dataIndex: 'display'
                },{
                    name: 'visible', dataIndex: 'visible', header: 'Visible'
                },{
                    name: 'default', dataIndex: 'isDefault', header: 'Default'
                }]
    });
    this.callParent(arguments);

  4. #4
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,337
    Answers
    101
    Vote Rating
    75
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    OK, your problem is *not* the Store:

    Code:
    
            Ext.require('Ext.data.Store');
    
    
            Ext.onReady(function() {
                var store = Ext.create('Ext.data.Store', {
                    fields: ['value', 'display', 'visible', 'isDefault' ],
                    autoLoad: true,
                    data: [
                     { value: 'A', display: ' Display A', visible: false, isDefault: false },
                     { value: 'B', display: 'Display B', visible: false, isDefault: false },
                     { value: 'C', display: 'Display C', visible: false, isDefault: false }
                    ],
                    proxy: {
                        type: 'memory',
                        reader: { type: 'json', root: 'data', idProperty: 'value' }
                    }
                });
    
                var rec = store.findRecord( 'value', 'A' );
    
                rec.beginEdit();
                rec.set('isDefault', true);
                rec.endEdit();
                rec.commit();
                console.log(rec.data)
    
            });
    That works fine.

  5. #5
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,337
    Answers
    101
    Vote Rating
    75
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    The problem is actually in the panel.Table class itself

    It's fixed in Ext JS 4.0.6 (to be released in the future). I highly suggest you consider looking at better formatted code and learn to do so.
    Code:
     Ext.require(['Ext.data.Store', 'Ext.grid.Panel', 'Ext.grid.plugin.CellEditing']);
    
            Ext.onReady(function () {
                var store = Ext.create('Ext.data.Store', {
                    fields: ['value', 'display', 'visible', 'isDefault'],
                    autoLoad: true,
                    data: [{
                        value: 'A',
                        display: ' Display A',
                        visible: false,
                        isDefault: false
                    }, {
                        value: 'B',
                        display: 'Display B',
                        visible: false,
                        isDefault: false
                    }, {
                        value: 'C',
                        display: 'Display C',
                        visible: false,
                        isDefault: false
                    }],
                    proxy: {
                        type: 'memory',
                        reader: {
                            type: 'json',
                            root: 'data',
                            idProperty: 'value'
                        }
                    }
                });
    
                var grid = Ext.create('Ext.grid.Panel', {
                    renderTo: Ext.getBody(),
                    height: 200,
                    width: 400,
                    store: store,
                    plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
                        clicksToEdit: 1
                    })],
                    selType: 'cellmodel',
                    columns: [{
                        name: 'display',
                        dataIndex: 'display'
                    }, {
                        name: 'visible',
                        dataIndex: 'visible',
                        header: 'Visible'
                    }, {
                        name: 'default',
                        dataIndex: 'isDefault',
                        header: 'Default'
                    }],
                    buttons: [{
                        text: 'Do Update',
                        handler: function () {
                            var rec = store.findRecord('value', 'A');
    
                            rec.beginEdit();
                            rec.set('isDefault', true);
                            rec.endEdit();
                            rec.commit();
                            console.log(rec.data)
    
                        }
                    }]
    
                });
    
    
            });

  6. #6
    Sencha User
    Join Date
    Mar 2009
    Posts
    84
    Answers
    1
    Vote Rating
    0
    Speedy is on a distinguished road

      0  

    Default


    thanks for the try but the beginEdit(), endEdit(), commit() doesnt work.

    I tried that before too

    Code:
    console.log('Before End Edit');
    rec.endEdit();
    console.log('End Edit done');
    rec.commit();
    console.log('Commit done');
    the only output before the error is the 'Before End Edit'

  7. #7
    Ext JS Premium Member
    Join Date
    May 2009
    Posts
    55
    Answers
    1
    Vote Rating
    0
    bodyboarder20 is on a distinguished road

      0  

    Default


    @Speedy

    Quote Originally Posted by jgarcia@tdg-i.com View Post
    The problem is actually in the panel.Table class itself

    It's fixed in Ext JS 4.0.6 (to be released in the future).

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar