我有一个典型的制表器设置 keybindings:{"navUp" :"38","navDown" :"40","navLeft" :"37","navRight" :"39"}
已启用。
编辑单元格时,它会成功更新数据并以编程方式移动到下面的下一个单元格
cellEdited:function(cell){
let updateValue = updateValueQuery(columnIndex,rowIndex,cell.getValue()).then(function(done){
cell.nav().down();
});
}
当在新的单元格中时,rowId 不会改变(其行为与 rowClick 不同)
我想弄清楚的是:如何获取 row.getIndex();
cellEdited:function(cell){}
里面
cellEdited:function(cell){
// ->> How i can obtain rowIndex = row.getIndex(); here or if there is another more optimal way.
let updateValue = updateValueQuery(columnIndex,rowIndex,cell.getValue()).then(function(done){
cell.nav().down();
});
}
我尝试将行属性放入 cellEdited:function(cell,row)
但运气不好。
任何帮助将不胜感激! 感谢您的宝贵时间!
最佳答案
我不确定我是否理解您的问题,但您可以通过 cell component 访问该行方法
var row = cell.getRow();
您也可以只获取数据而不遍历行:
Get Data
The getData function returns the data for the row that contains the cell.
var dataID = cell.getData().id;
// the name of the property you are using for the index
或者使用getIndex
Get Index
The getIndex function returns the index value for the row. (this is the value from the defined index column, NOT the row's position in the table)
var rowIndex = row.getIndex();
如果你想获取下一个或上一个逻辑行,可以使用 row component 的方法:
Get Next Row
The getNextRow function returns the Row Component for the next visible row in the table, if there is no next row it will return a value of false.
var nextRow = row.getNextRow();
var prevRow = row.getPrevRow();
最后:
Get Position
Use the getPosition function to retrieve the numerical position of a row in the table. By default this will return the position of the row in all data, including data currently filtered out of the table.
If you want to get the position of the row in the currently filtered/sorted data, you can pass a value of true to the optional first argument of the function.
var rowPosition = row.getPosition(true);
//return the position of the row in the filtered/sorted data
关于javascript - 如何从 cellEdited :function(cell)? 获取行索引 - 制表符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67278687/