Getting data from cells in SlickGrid

巧了我就是萌 提交于 2019-12-10 13:32:22

问题


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!


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/4210120/getting-data-from-cells-in-slickgrid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!