0

ExtJs is a new world for me. I hope I can get the problem explained very well.

I have a grid with different editor columns. If I change one and save it, I have to change the output.

I do it with

   e.row.cells[e.colIdx].childNodes[0].innerText = '{s name=column/express/yes}JA{/s}';
    e.row.cells[e.colIdx].classList.add("warning");

If I change 2 different fields at the same time, e.colIdx does not fit anymore to the right column.

Is there a getter or anything else to get the column of a special grid column ?

Here is the complete code

   onSavePosition: function(editor, e, store, options) {
    var me = this,positionStore;
    if (((e.newValues.md_express != e.originalValues.md_express) && e.record.internalId > 0)
        || e.newValues.md_supplier != e.originalValues.md_supplier) {
            var customCallback = function (position, success) {
                Ext.Ajax.request({
                    method: 'POST',
                    url: '{url controller=AttributeData action=saveData}',
                    params: {
                        _foreignKey: e.record.internalId,
                        _table: 's_order_details_attributes',
                        __attribute_md_express: Number(e.newValues.md_express),
                        __attribute_md_supplier: e.newValues.md_supplier
                    },
                    success:function(response){
                        var t=this;
                        me.getOrderList().store.load();
                        var selectedRowIndex=e.grid.getSelectionModel().getCurrentPosition().row;
                        var selectedRowRecord=e.grid.getStore().getAt(selectedRowIndex);
                        selectedRowRecord.set('md_express',e.newValues.md_express);
                        selectedRowRecord.set('md_supplier',e.newValues.md_supplier);
                        selectedRowRecord.commit();

                        debugger;
                        if((e.newValues.md_express != e.originalValues.md_express)) {
                            if (e.newValues.md_express == true) {
                                e.row.cells[e.colIdx].childNodes[0].innerText = '{s name=column/express/yes}JA{/s}';
                                e.row.cells[e.colIdx].classList.add("warning");
                            } else {
                                e.row.cells[e.colIdx].childNodes[0].innerText = '{s name=column/express/no}NEIN{/s}';
                                e.row.cells[e.colIdx].classList.remove("warning");
                            }
                        }


                    }
                });
            };


            options.callback = customCallback;
    }

    me.callParent([editor, e, store, options]);
}
megadruck
  • 427
  • 1
  • 6
  • 13
  • Are you talking about an ExtJS grid or a HTML table? Because if it is an ExtJS grid, please look at the [basic samples of grids with editors](http://examples.sencha.com/extjs/6.0.2/examples/kitchensink/#cell-editing). – Alexander Apr 11 '17 at 17:24

1 Answers1

0

my solution is

var colIdx = me.getColumnIndex(editor.grid,'md_express');


    getColumnIndex: function(grid, dataIndex) {
    gridDataIndices = Ext.Array.pluck(grid.columns, 'dataIndex');
    return Ext.Array.indexOf(gridDataIndices, dataIndex);
}

this sends back the column index of the given column in my grid.

Found here how to find column index using dataIndex Extjs 4

Community
  • 1
  • 1
megadruck
  • 427
  • 1
  • 6
  • 13