从SlickGrid中的单元格获取数据 [英] Getting data from cells in 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屋!