6

What method do I use for SlickGrid to get the cell contents? For example:

...
grid = new Slick.Grid($("#myGrid"), data, columns, options);
grid.onAddNewRow = function(item,colDef) {
  grid.removeRow(data.length);
  data.push(item);
  grid.updateRowCount();
  grid.render();
}

grid.onCurrentCellChanged = function(args){
  // get cell content!
};
...

Thanks in advance!

maximus
  • 2,417
  • 5
  • 40
  • 56

2 Answers2

7

The grid is modifying your data source directly, so the changes will be applied to "data". The "onCurrentCellChanged" event is fired when the user changes the active/selected cell, and gets {row:currentRow, cell:currentCell} as a parameter. To get to the cell data, you can use data[args.row][grid.getColumns()[args.cell].field], assuming you are using the column.field to access the data and not a custom formatter that gets the data in some other way.

Tin
  • 9,082
  • 2
  • 34
  • 32
2

grid.onCurrentCellChanged seems to have changed to grid.onActiveCellChanged.subscribe in 2.0

animuson
  • 53,861
  • 28
  • 137
  • 147
pmagunia
  • 1,718
  • 1
  • 22
  • 33
  • 1
    Looks like onActiveCellChanged occurs when the user focuses on a different cell for editing. For changes in the value of the data in the cell, you want grid.onCellChange.subscribe. – E.Z. Hart May 21 '12 at 16:17