yui datatable内联单元格编辑器问题
在我的数据表中使用内联单元格编辑器时,我想将值舍入为 10 的倍数
这是我的代码:
mydatatable.subscribe("cellDblclickEvent",datatable_DetailsCommande.onEventShowCellEditor);
var onCellEdit = function(oArgs) {
var oColumn=oArgs.editor.getColumn();
var column=oColumn.getKey();
var oRecord = oArgs.editor.getRecord();
var newValue=oRecord.getData(column);
var row = this.getRecord(oArgs.target);
// calculate the modulo
n = newValue % 10;
if(n!=0)
{
newValue=parseInt(newValue);
oRecord.setData(column,eval(newValue+(10-n)));
}
}
mydatatable.subscribe("editorSaveEvent", onCellEdit);
函数结果:
双击单元格后,我将值更改为 17,然后单击“保存”,然后我希望数据表中有 20单元格,但我得到了 17。第二次双击我的数据表单元格后,我在内联单元格编辑器中得到了 20。
如何将舍入值放入我的数据表单元格中?
问候,
When using inline cell editor in my datatable I want to round value to 10 multiple
This is my code :
mydatatable.subscribe("cellDblclickEvent",datatable_DetailsCommande.onEventShowCellEditor);
var onCellEdit = function(oArgs) {
var oColumn=oArgs.editor.getColumn();
var column=oColumn.getKey();
var oRecord = oArgs.editor.getRecord();
var newValue=oRecord.getData(column);
var row = this.getRecord(oArgs.target);
// calculate the modulo
n = newValue % 10;
if(n!=0)
{
newValue=parseInt(newValue);
oRecord.setData(column,eval(newValue+(10-n)));
}
}
mydatatable.subscribe("editorSaveEvent", onCellEdit);
Function result :
After double clicking in cell I change value to 17 for example and I click save, I want then to have 20 in my datatable cell but I got 17. After second time double clicking in my datatable cell I obtain 20 in the inline cell editor.
How to put the rounded value in my datatable cell?
regards,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您在列定义中创建内联编辑器时,您可以指定一个验证器来执行舍入:
When you create your inline editor in your column definition you could specify a validator which will perform your rounding: