Results 1 to 2 of 2

Thread: Change event not firing.

  1. #1

    Question Change event not firing.

    I am using a GridPanel that is loaded from a remote store. On the same window, I also have a FormPanel (Ext.form.FormPanel) that has some text/combo fields corresponding to the GridPanel columns. I defined a selection change event for the selection model of the GridPanel.In the selection change, I look for change/select event on each of the text/combo field and set the grid selection record to the changed values of the form fields. So when I change a field but leave the cursor in that field and click on another row from the grid and go back to the previously changed row, it doesnt show the value obviously because the change event never fired. How can I fix this? Any ideas will be greatly appreciated.

    Here is the code.

    xtype: 'panel',
    items: [{
    xtype: 'grid',
    id: 'myGrid',
    store: store,
    columns: [
    { header: 'name', dataIndex: 'NAME'},
    { header: 'address', dataIndex: 'ADDRESS'},
    { header: 'dob', dataIndex: 'DOB'}
    ]},
    {xtype: 'textfield', fieldLabel: 'NAME', id: 'txtName' },
    {xtype: 'textfield', fieldLabel: 'ADDRESS', id: 'txtAddress' },
    {xtype: 'textfield', fieldLabel: 'DOB', id: 'txtDOB' }]



    var selChange = function(fld, col){
    Ext.getCmp('fld').on('change', function(f, changeval, oldval) {
    var grdRecord = Ext.getCmp('myGrid').getSelectionModel().getSelected();
    grdRecord.set(col, changeval);
    });
    };


    Ext.getCmp('myGrid').getSelectionModel().on({
    selectionchange: function (selmod) {
    var selectedRecord = sm.getSelected();
    //Change the grid selected rows values based on form values
    selChange('txtName', 'NAME'); //selChange function defined above
    selChange('txtAddress', 'ADDRESS');
    selChange('txtDOB', 'DOB');

    //Save new values to form field values
    Ext.getCmp('txtName').setValue(selectedRecord.get('NAME');
    Ext.getCmp('txtAdress').setValue(selectedRecord.get('ADDRESS');
    Ext.getCmp('txtDOB').setValue(selectedRecord.get('DOB');
    }
    });

  2. #2

    Default Fixed

    I fixed this by using keyup event instead of change event. Also I had to set 'enableKeyEvents' property on all my fields to true.

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
  •