JSGrid回调方法

时间:2015-08-04 18:25:16

标签: javascript jquery

我正在使用 JSGrid (js-grid.com)构建网格。我想要在添加新记录或更新记录之前回调方法来实现验证。网站上提供的文件没有明确提及如何实施。请参考http://js-grid.com/docs/#callbacks。 我需要帮助如何实现回调方法因为我是JSGrid&的新手脚本。以下是我的示例代码。请指导我在哪里放置回调方法。

    $(function() {

    $("#jsGrid").jsGrid({
        height: "90%",
        width: "100%",

        filtering: true,
        editing: true,
        sorting: true,
        paging: true,
        autoload: true,

        pageSize: 15,
        pageButtonCount: 5,

        deleteConfirm: "Do you really want to delete the client?",

        controller: db,

        fields: [
            { name: "Name", type: "text", width: 150 },
            { name: "Age", type: "number", width: 50 },
            { name: "Address", type: "text", width: 200 },
            { name: "Country", type: "select", items: db.countries, valueField: "Id", textField: "Name" },
            { name: "Married", type: "checkbox", title: "Is Married", sorting: false },
            { type: "control" }
        ]
    });

});

先谢谢。

1 个答案:

答案 0 :(得分:0)

$(function() {

$("#jsGrid").jsGrid({
    height: "90%",
    width: "100%",

//为演示添加

onItemInserting: function(args) {},  // before controller.insertItem
onItemInserted: function(args) {},   // on done of controller.insertItem
onItemUpdating: function(args) {},   // before controller.updateItem
onItemUpdated: function(args) {},    // on done of controller.updateItem
onItemDeleting: function(args) {},   // before controller.deleteItem
onItemDeleted: function(args) {},    // on done of controller.deleteItem

    filtering: true,
    editing: true,
    sorting: true,
    paging: true,
    autoload: true,

    pageSize: 15,
    pageButtonCount: 5,

    deleteConfirm: "Do you really want to delete the client?",

    controller: db,

    fields: [
        { name: "Name", type: "text", width: 150 },
        { name: "Age", type: "number", width: 50 },
        { name: "Address", type: "text", width: 200 },
        { name: "Country", type: "select", items: db.countries, valueField: "Id", textField: "Name" },
        { name: "Married", type: "checkbox", title: "Is Married", sorting: false },
        { type: "control" }
    ]
});

});