Dojo gridx: using "onAfterRow" disables "onCellWidgetCreated"?

625 views Asked by At

When creating a gridx, I use the following column definition to insert an Edit button in to the last cell of each row:

var editColumn = { field : 'Edit', name : '', widgetsInCell: true,
        onCellWidgetCreated: function(cellWidget, column){
            var btn = new Button({
                label : "Edit",
                onClick : function() {
                  console.log('Do stuff here');
            });
            btn.placeAt(cellWidget.domNode);
        }
    };
columns.push(editColumn);
var grid = new Grid({
        cacheClass : Cache,
        store : store,
        structure : columns,
        modules: ["gridx/modules/CellWidget"]
    }, 'gridNode');

 grid.body.onAfterRow = function(row){

        ...do stuff on the row here
    };

Whne I include the onAfterRow function the row processing happens but the OnCellWidgetCreated does not. Each function seems wo work in absence of the other. Any suggestions on how I can: (1) format the rows according to row data AND (2) insert the button widgets in the last cell of each row?

1

There are 1 answers

1
Eduardo On

Ok, solved it. Rather than assign the grid.body.onAfterRow, the way that worked for me was:

   aspect.after(grid.body,'onAfterRow',function(row){
        key = row.id;
        if ('anulada' in row.grid.store.get(key)){
            if(row.grid.store.get(key).anulada == true){
                row.node().style.color = 'gray';
            }
        } 
    },true);

You need to require "dojo/aspect".