jQuery MiniUI

标题: 关于onCellValidation验证,如何设置单元格值 [打印本页]

作者: joney    时间: 2015-7-15 17:03:59     标题: 关于onCellValidation验证,如何设置单元格值

数据验证发现所填写的值不在允许范围内,警告后如何自动把值修正(程序自动填写正确的值)

function onCellValidation(e) {
                var record=e.record
                //var editor=e.editor
                //alert(editor.getValue())
                //alert(e.value)
                if (e.field == "allowGDeliveryAmount") {
                        var usefullAmount=parseInt(record.buyAmount)-parseInt(record.deliveryAmount);
                        if (e.value > parseInt(usefullAmount)) {
                                e.isValid = false;                               
                                alert("生成发货单数量不允许大于可用数量!");
                                //e.errorText = "生成发货单数量不允许大于可用数量!";
                                //editor.value=usefullAmount;
                                //e.cancel = true;
                                //e.value=usefullAmount;
                                //e.cellHtml=usefullAmount;
                                //e.setValue(usefullAmount);
                        }
                }
        }
作者: dforce    时间: 2015-7-15 17:25:40

验证事件里无法更新数据
你要更新的只能grid.updateRow(row,{field:value})来更新
作者: joney    时间: 2015-7-15 18:15:26

dforce 发表于 2015-7-15 17:25
验证事件里无法更新数据
你要更新的只能grid.updateRow(row,{field:value})来更新

谢谢!
那在onCellValidation(e)方法里如何获得grid对象?因为有很多个grid是动态生成的,如果在onCellValidation(e)这个方法识别不到哪个grid的话,就要对每个grid对应写个onCellValidation(e)方法,比较麻烦。
作者: felt    时间: 2015-7-16 09:22:24

joney 发表于 2015-7-15 18:15
谢谢!
那在onCellValidation(e)方法里如何获得grid对象?因为有很多个grid是动态生成的,如果在onCellVa ...

e.sender就是表格对象
作者: joney    时间: 2015-7-16 15:40:30

felt 发表于 2015-7-16 09:22
e.sender就是表格对象

搞定了,非常感谢!!




欢迎光临 jQuery MiniUI (http://miniui.com/discuss/) Powered by Discuz! X2