4

I have grid with RowEditing plugin. Editor has 2 columns: one with combobox and another with disabled textfield.

I need to change textfield value after changing the combobox value.

I have combobox listener:

listeners = {
       select: function (combo, records) {
            var editorRecord = myGrid.getPlugin('rowEditPlugin').editor.getRecord();
            editorRecord.data["SomeCol"] = "SomeValue";
       }
}

But value in the textfield does not refresh until another calling of roweditor.

I need just to set text value to the cell, without updating store. And also if I click cancel button of roweditor, I need cell value returning to old one.

Thanks for your time, all replies and all help.

tytyryty
  • 741
  • 7
  • 17

1 Answers1

5

You can change it using the selection model of the grid,something like this :

   {
     text: 'Type',
     dataIndex: 'type',
     editor: {
         xtype: 'combo',
         typeAhead: true,
         selectOnTab: true,
         displayField:"name",
         listeners: {
               select: function(combo, records) {
                   myGrid= this.up('grid');
                   var selectedModel = this.up('grid').getSelectionModel().getSelection()[0];
                   //selectedModel.set('dataIndexOfNextCol', "Success");
                   val = combo.getValue();
                    if(val == 'type1'){
                         Ext.getCmp('textFld').setValue("success");
                     }
                     else{
                         Ext.getCmp('textFld').setValue("failure");
                     }
           }
  },
  {
    text: 'Item',
    dataIndex: 'item',
    editor: {
               xtype: 'textfield',
               id: 'textFld'
           }
  }

You have to commit the changes on update.So you can call edit event listener,

listeners: {
    edit: function(editor, e) {
        e.record.commit();
    }
},

For reference , have a look at this DEMO

Dev
  • 3,922
  • 3
  • 24
  • 44
  • Thanks for reply. This solution work but it refresh value in grid and in RowEditing plugin after closing of RowEditing. But I need some way to refresh RowEditing values at once, immediately after value changing in combobox. – tytyryty Jun 26 '14 at 07:47
  • Thanks. But is there any solution without Ext.getCmp or Ext.ComponentQuery.query? For example somehow get this textfield from selectedModel or from RowEditing record? – tytyryty Jun 26 '14 at 09:57
  • You can try getting like this : `txtFld = myGrid.getPlugin('roweditor').editor.down('textfield[name=item]');` – Dev Jun 26 '14 at 10:05
  • Thanks Dev, this is exactly what I wanted, and also without updating store when cancelling rowediting! – tytyryty Jun 26 '14 at 10:33
  • 2
    I found that instead of `editor.down('textfield[name="name"]').setValue("value");` it also this can be done with `editor.form.findField("name").setValue("value");` – tytyryty Jun 27 '14 at 10:53