Search code examples
extjsextjs4.1extjs5

Populate Field based on another Combo Box in grid of extjs


In grid i have three column on column field have combo box and on change of combo box value auto populate another column respective field How to do this extjs

enter image description here

Please see above image for grid code.

My Function is below

autoPopulateCsid: function(grid, rowIndex, colIndex, item, e, record, row, action) {

/// i am not able to get whole record/row of grid which i am editing

}

i have to get record in function so i can update field of record and it will be dirty automatic. So on cancel i will discard all my changes for that perticular row


Solution

  • The combobox select event don't have all these parameters, the parameters it actually receives are combobox, newValue, oldValue, eOpts from there you can get your "row record" from your editor componenet like this.

    autoPopulateCsid: function(combobox, newValue, oldValue, eOpts) {
        let myRecord = combobox.up('editor').context.record;
         myRecord.set('collateralAgreement',newValue);
    
    }
    

    If you dont use myRecord.commit(), the record will be marked as dirty, after that if you want to discard those changes you can use rejectChanges() in the store of your grid.