Results 1 to 6 of 6

Thread: Not getting the record after editing in afteredit using RowEditor

  1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    15
    Answers
    2
    Vote Rating
    0
      0  

    Default Answered: Not getting the record after editing in afteredit using RowEditor

    I am getting the record in the afteredit event of the RowEditor. Here is my code:

    Code:
    <script type="text/javascript">
            Ext.Loader.setConfig({ enabled: true });
            Ext.require([
                'Ext.grid.*',
                'Ext.data.*',
                'Ext.util.*',
                'Ext.toolbar.Paging',
                'Ext.ModelManager',
                'Ext.tip.QuickTipManager'
            ]);
    
    
            Ext.onReady(function () {
                var model = Ext.define('Employee', {
                    extend: 'Ext.data.Model',
                    fields: ['EmpID', 'FirstName', 'LastName', 'Email'],
                    idProperty: 'EmpID'
                });
                var store = Ext.create('Ext.data.Store', {
                    storeId: 'empStore',
                    model: 'Employee',
                    //                autoLoad: true,
                    pageSize: 5,
                    proxy: {
                        type: 'ajax',
                        url: 'AddOffice.aspx/GetEmployees',
                        headers: {
                            'Content-Type': 'application/json'
                        },
                        reader: {
                            type: 'json',
                            root: 'd.Records',
                            totalProperty: 'd.TotalRecords',
                            successProperty: 'success'
                        }
                    }
                });
                store.load({ params: {
                        start: 0,
                        limit: 5
                    } 
                });
                var editor = Ext.create('Ext.grid.plugin.RowEditing', {
                    clicksToEdit: 1
                });
                editor.on({
                    scope: this,
                    afteredit: function (roweditor, changes, record, rowIndex) {                    
                        alert(record);
                    }
                });
                var grid = Ext.create('Ext.grid.Panel', {
                    title: 'Employees',
                    store: store,
                    id: 'EList',
                    height: 200,
                    width: 500,
                    loadMask: true,
                    plugins: [editor],
                    renderTo: Ext.getBody(),
                    selType: 'rowmodel',
                    columns: [
                            { header: 'Employee ID', dataIndex: 'EmpID', flex: 1, hidden: true },
                            { header: 'First Name', dataIndex: 'FirstName', flex: 1, editor: { allowblank: false} },
                            { header: 'Last Name', dataIndex: 'LastName', flex: 1, editor: { allowblank: false} },
                            { header: 'Email', dataIndex: 'Email', flex: 1, editor: { allowblank: false, vtype: 'email'} }
                        ],
                    bbar: Ext.create('Ext.PagingToolbar', {
                        store: store,
                        pageSize: 5,
                        displayInfo: true
                    })
                });
                //            grid.renderTo(Ext.getBody);
            });
        </script>

  2. With Ext 4.0, you should use
    Code:
        editor.on({
             scope: this,
             edit: function(event){
                   alert(event.record);
            }
       });
    But with Ext 4.1, you should use
    Code:
        editor.on({
             scope: this,
             edit: function(roweditor, event){
                   alert(event.record);
            }
       });
    I guess you are using Ext 4.0.x.

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,409
    Answers
    716
    Vote Rating
    504
      0  

    Default

    Does your server return the record after editing? Can you see the updated record in your response tab using FireBug?

    Regards,
    Scott.

  4. #3
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    118
      0  

    Default

    editor.on({
    scope: this,
    afteredit: function (roweditor, changes, record, rowIndex) {
    alert(record);
    }
    });
    As I known with Ext 4.x, Ext.grid.plugin.RowEditing fires 'afteredit' event which is in fact 'edit' event with the following arguments
    Code:
    edit( Ext.grid.plugin.Editing editor, Object e, Object eOpts )
    So, let have a try by modifying your code as below
    Code:
                editor.on({
                    scope: this,
                    edit: function (roweditor, event) {                    
                        alert(event.record);
                    }
                });

  5. #4
    Sencha User
    Join Date
    Mar 2012
    Posts
    15
    Answers
    2
    Vote Rating
    0
      0  

    Default

    Hi vietits,
    This doesnot work either. I still the get the record as undefined
    Code:
        editor.on({
             scope: this,
             edit: function(roweditor, event){
                   alert(event.record);
            }
       });
    The following code works for me:
    Code:
        editor.on({
             scope: this,
             edit: function(roweditor, event){
                   alert(roweditor.record);
            }
       });

  6. #5
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    118
      0  

    Default

    With Ext 4.0, you should use
    Code:
        editor.on({
             scope: this,
             edit: function(event){
                   alert(event.record);
            }
       });
    But with Ext 4.1, you should use
    Code:
        editor.on({
             scope: this,
             edit: function(roweditor, event){
                   alert(event.record);
            }
       });
    I guess you are using Ext 4.0.x.

  7. #6
    Sencha User
    Join Date
    Mar 2012
    Posts
    15
    Answers
    2
    Vote Rating
    0
      0  

    Default

    Hi Vietits,
    Yes you are right. Thanks for the answer.


Posting Permissions

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