从SlickGrid中的单元格获取数据 [英] Getting data from cells in SlickGrid

查看:371
本文介绍了从SlickGrid中的单元格获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用什么方法为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!
};
...

提前致谢!

推荐答案

网格正在直接修改数据源,因此更改将应用​​于数据。
当用户更改活动/选定单元格时会触发onCurrentCellChanged事件,并将{row:currentRow,cell:currentCell}作为参数。要获取单元格数据,可以使用 data [args.row] [grid.getColumns()[args.cell] .field] ,假设您使用的是列.field访问数据而不是以其他方式获取数据的自定义格式化程序。

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.

这篇关于从SlickGrid中的单元格获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆