0
votes

I have a grid which has a column with editor defined like below.

   this.accrualGrid = new Ext.grid.GridPanel({
        store: store,
        id:'accrualGrid_add',
        plugins :[this.cellEditing],
        columns: [

            {header: 'Milestone Description', width: 340, dataIndex: 'Description',

                getEditor: function(record) {
                    if(Ext.getCmp('accrualGrid_add').store.indexOf(record)==0)
                    {
                        return Ext.create('Ext.grid.CellEditor', {

                            field: Ext.create('Ext.form.field.Text', {

                                id:'MDesc_Add',
                                validator:function(val){
                                    if(val=="")
                                      return false;
                                    else
                                      return true;
                                },
                            })
                        });

                   }

                }
            }]

Everytime the grid the loaded, I am not able the access the textfield inside editor until we click on that cell.

Ext.getCmp('MDesc_Add') gives undefined value.

After I click on that cell, It gives me the textfield object.

How can I access the textfield object just on grid load or set data of grid??

1
What are you trying to achieve?Evan Trimboli
I want to validate the value in the field( and show red border if invalid) when the data is set , not on clicking of fieldAngryLeo

1 Answers

1
votes

This is because you instantiate the field inside the getEditor method, which is called only when the editor is needed (when it should be displayed).

If you want the field to be always available, you should instantiate it before you instantiate the grid:

var editorField = Ext.create('Ext.form.field.Text', {
        id:'MDesc_Add',
        validator:function(val){
        if(val=="") return false;
        else return true;
    });
this.accrualGrid = new Ext.grid.GridPanel({
    ...
              return Ext.create('Ext.grid.CellEditor', {
                  field: editorField
              });
    ...
});