Results 1 to 7 of 7

Thread: Why do unchanged cells become blank on ajax updating ?

  1. #1
    Sencha User
    Join Date
    Oct 2008
    Posts
    81

    Default Why do unchanged cells become blank on ajax updating ?

    I have a GridPanel using a BufferView and a RowEditor :
    when I update one cell the other cells of the Row becomes blank. Why ?

    Here is my code :
    Code:
        var record_members_listing = Ext.data.Record.create([
        {
            name: 'id',
            type: 'int'
        },    {
            name: 'name',
            type: 'string'
        },    {
            name: 'usertype',
            type: 'string'
        }
        ]);
    
        var reader_members_listing = new Ext.data.JsonReader({
            root: 'rows',
            idProperty: 'id',
            successProperty: 'success',
            fields: record_members_listing
        });
    
        var store_members_listing = new Ext.data.Store({
            storeId: 'id-store_members_listing',
            url: './../../my/members_listing.php',
            reader: reader_members_listing,
            writer: new Ext.data.JsonWriter()
        });
    
        var editor_members_listing = new Ext.ux.grid.RowEditor({
            id: 'id-editor_members_listing',
            saveText: 'OK',
            cancelText: 'Cancel',
            commitChangesText: 'Please confirm or cancel',
            errorText: 'Error'
            });
    
        table_members_listing = new Ext.grid.GridPanel({
            id: 'id-table_members_listing',
            region:'center',
            store: store_members_listing,
            sm: new Ext.grid.RowSelectionModel({
                singleSelect: true
            }),
            view: new Ext.ux.grid.BufferView({
                scrollDelay: false
            }),
    
            columns: [
                new Ext.grid.RowNumberer(),
                { id: 'id-col', header: '', width: 10, dataIndex: 'id', filterable: true, sortable: true, hidden: true }, {
                        id: 'name-col',
                        header: 'Name',
                        dataIndex: 'name',
                        editor: { xtype: 'textfield'}
                    }, {
                        id: 'name-col',
                        header: 'User Type',
                        dataIndex: 'usertype',
                        editor: {
                            xtype: 'textfield'
                        }
                    }
            ],
            plugins: [ editor_members_listing ],
            tbar: [],
            loadMask: true,
            listeners: {
                beforerender: function( gridpanel ) {
                    store_members_listing.load();
                }
            }
        });
    When User Type is unchanged
    JSON sent is :
    Code:
    {"success":true,"rows":{"name":"Christopher SMITH","id":"608"}}
    and this blanks the "User Type" in the row,

    as when I change also the User Type JSON sent is :
    Code:
    {"success":true,"rows":{"name":"Christopher  SMITH","usertype":"member", "id":"608"}}
    which shows correct in the row.

    Do I have to transmit all the fields in the row?
    Or to take a specific action?
    Or some parameter to set to keep showing the unchanged cells of the row?

  2. #2

    Default

    Yes you must transmit all the fields...

  3. #3
    Sencha User
    Join Date
    Oct 2008
    Posts
    81

    Default

    Quote Originally Posted by darthwes View Post
    Yes you must transmit all the fields...
    Thank you for the hint.
    It seems that only the modified cells are transmitted + the id by the RowEditor.
    Where can I set or change something to have all cells transmitted ?

    Another solution would be to ask the server to request the full row and send it back.

    The best solution would still be to have no modification after the response from the server,
    or only the cells that deserve it without blanking the others.

    For the present, I fire a load() :
    Code:
        var editor_members_listing = new Ext.ux.grid.RowEditor({ 
           id: 'id-editor_members_listing',        
           saveText: 'OK', 
           cancelText: 'Cancel', 
           commitChangesText: 'Please confirm or cancel',
           errorText: 'Error',
           listeners : {           
           afteredit : {
                    fn : function(rowEditor, obj, data, rowIndex ){
                        store_members_listing.load(); }
                }
    });
    which is not very good because it jumps to the begining of the table, loosing the focus.
    (better would be to refresh only the row : how ?)

  4. #4

  5. #5
    Sencha User
    Join Date
    Oct 2008
    Posts
    81

    Default

    Thousand thanks, Animal : it does the job !

  6. #6

    Default

    Sorry for being useless, I appreciate code being given. I just pasted your code and saw initial load wasn't sending all fields... Thanks Animal.

  7. #7
    Sencha User
    Join Date
    Oct 2008
    Posts
    81

    Default

    A functional side effect of this is that the server receiving now all the fields does not know anymore which ones have been changed.
    For instance, let suppose I have some actions to take when the usertype changes.

    Of course, I can retreive the old values from the database, make a comparison and decide if anything has to be done if the usertype appears changed. Well that's a bit heavy.

    Is there an elegant way to send to the server the old values from the client ? So if the usertype goes from, let say, Author to Admin, the rigth actions can be taken altogether with the updating ?

Similar Threads

  1. Panel's own Renderer with ajax updating
    By radke in forum Ext 2.x: Help & Discussion
    Replies: 8
    Last Post: 1 Apr 2009, 6:07 AM
  2. updating panel with ajax.
    By leandrorc in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 28 Jun 2008, 5:22 PM
  3. Json/Ajax, force combobox updating
    By v0n in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 9 Jun 2008, 8:00 AM
  4. Getting data back in XML and updating fields using AJAX
    By Akansha in forum Ext 1.x: Help & Discussion
    Replies: 11
    Last Post: 7 Jan 2008, 2:12 PM

Posting Permissions

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