Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting data from cells in SlickGrid

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!

like image 777
maximus Avatar asked Nov 17 '10 23:11

maximus


2 Answers

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.

like image 111
Tin Avatar answered Nov 03 '22 00:11

Tin


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

like image 2
pmagunia Avatar answered Nov 03 '22 00:11

pmagunia