首页 > 解决方案 > 如何在 jsGrid 中自定义验证器警报?

问题描述

我找不到在 jsGrid 中自定义验证器警报的方法。我可以更改验证规则,但我需要使用自定义函数并删除警报。

我也找不到对输入的无效数据的引用!消息,这是required警报中的默认值。

我尝试遵循 github 中一些主题的一些提示,我也按照文档使用invalidNotify,但没有成功。

我正在尝试使用自定义函数,它除了验证已经在布局中进行了一些更改以通知插入的数据无效。

但是,标准的 jsGrid 警报不断弹出,如下所示:

fields: [{
            name: "sensorNumber",
            title: $('#title_meter_number').val(),
            type: "number",
            validate: function(config) {
                if (config == undefined) {
                    __validateRefuelling(config);
                }

标签: javascriptjsgrid

解决方案


我得到了它invalidNotify,我以前错误地使用过它,它遵循我的代码:

var xxx = function() {
    $('#xxx').jsGrid({
        height: '250px',
        width: '100%',
        inserting: true,
        editing: true,
        sorting: true,
        invalidNotify: function(args) {
            $('#alert-error-not-submit').removeClass('hidden');
        },
        fields: [{
            name: "sensorNumber",
            title: $('#title_meter_number').val(),
            type: "number",
            validate: "required"
        }, {
            name: "liters",
            title: $('#title_liters').val(),
            type: "number",
            validate: "required"
        }, {
            name: "measuredValue",
            title: $('#title_indication_of_the_meter').val(),
            type: "number",
            validate: "required"
        }, {
            type: "control"
        }]
    });
};

推荐阅读