0

内部に多数のパラメーターと関数を含む JavaScript があります。

 ctrl.kendoGrid({
 dataSource: {
    type: "odata",
    transport: {
        read: {
            url: "odata/CodeView",
            dataType: "json",
            contentType: "application/json"
        },
        update: {
            url: function (data) {
                return "api/CodeMapUpdate/" + data.CODE_MAP_ID;
            },
            dataType: "json",
            type: "post",
            complete: function (e) {
                ctrl.data("kendoGrid").dataSource.read();
                if (e.status == 201) {
                    logger.log("Record Updated: Record ID = " + e.responseJSON, null, null, true);
                } else {
                    logger.logError(" Save failed " + e.responseJSON.ExceptionMessage, null, null, true);
                }

            }
        },
        destroy: {
            url: function (data) {
                return "api/CodeMapDelete/" + data.CODE_MAP_ID;
            },
            dataType: "json",
            complete: function () {
                ctrl.data("kendoGrid").dataSource.read();
            }
        },
        create: {
            url: "api/CodeMapCreate",
            dataType: "json",
            complete: function (e) {
                ctrl.data("kendoGrid").dataSource.sort({
                    field: "CODE_MAP_ID",
                    dir: "desc"
                });
                ctrl.data("kendoGrid").dataSource.filter({});
                if (e.status == 201) {
                    logger.log("Record Created: Record ID = " + e.responseJSON, null, null, true);
                } else {
                    logger.logError(" Save failed " + e.responseJSON.ExceptionMessage, null, null, true);
                }

            }
        },
    },
    schema: {
        data: function (data) {
            return data.value;
        },
        total: function (data) {
            return data["odata.count"];

        },
        model: {
            id: "CODE_MAP_ID",
            fields: {
                CODE_MAP_ID: {
                    editable: false,
                    type: "number"
                },
                CODE_NAME: {
                    type: "string",
                    validation: {
                        title: "Required Field",
                        required: true
                    }
                },
                L_NAME: {
                    type: "string",
                    validation: {
                        required: true
                    }
                },
                CODE_DATE: {
                    field: "CODE_DATE",
                    type: "date",
                    format: "{0:MM/dd/yyyy}",
                    validation: {
                        required: true
                    }
                },
            }
        }
    },
    change: function () {

    },
    //batch: true,
    pageSize: 20,
    serverPaging: true,
    serverFiltering: true,
    serverSorting: true,
    sort: {
        field: "CODE_MAP_ID",
        dir: "desc"
    }
    //autoSync: true
} })

「dataSource」オブジェクト全体を変数として保存し、実行時にajaxで取得しようとしています。
eval ("(" + dataSource + ")") でこれを行うことができますが、含まれている関数は実行されなくなりました。

このタイプのオブジェクトを JSON との間で保存/取得する戦略に関するアイデアはありますか?

4

1 に答える 1