paramQuery。如何显示远程错误消息?

时间:2019-02-08 10:26:35

标签: javascript ajax validation jquery-ui paramquery

$.ajax({
        dataType: "json",
        type: "POST",
        async: true,
        beforeSend: function (jqXHR, settings) {
            grid.showLoading();
        },
        url: "/controller/update", 
        data: { list: JSON.stringify(changes) },
        success: function (changes) {
            //Here i can get array of errors from saving.

            grid.commit({ type: 'add', rows: changes.addList });
            grid.commit({ type: 'update', rows: changes.updateList });
            grid.commit({ type: 'delete', rows: changes.deleteList });

            grid.history({ method: 'reset' });
        },
        complete: function () {
            grid.hideLoading();
        }
    });

将数据发送到服务器后,我会收到一些错误消息,这些错误消息无法通过远程验证器进行检查,但应该在网格上显示。 如何获取当前单元格的UI对象以为工具提示设置msg

类似这样的东西

validations: [
                { type: 'minLen', value: 1, msg: "Required" },
                { type: function (ui) {
                    var value = ui.value,
                        _found = false;
                    //remote validation
                    //debugger;
                    $.ajax({
                        url: "/pro/demos/checkCountry",
                        data: { 'country': value },
                        async: false,
                        success: function (response) {
                            if (response == "true") {
                                _found = true;
                            }
                        }
                    });
                    if (!_found) {
                        ui.msg = value + " not found in list";
                        return false;
                    }
                }
                }
            ]

,但经过一般验证。 这是远程验证的示例

0 个答案:

没有答案