Kendo dataSource参数图 [英] Kendo dataSource Parameter Map

查看:64
本文介绍了Kendo dataSource参数图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是剑道新手。我遇到模型绑定问题。当我使用firebug进行调试时,它会显示 options.models undefined 。由于这个原因,parrameterMap中的if条件始终为false,并且grid不会填充数据。 但是当我删除parrameterMap部分时,它可以工作。
我认为,如果有人可以解释一下kendo dataSource中的参数映射,那将非常有用。
谢谢。

I am new to kendo. I'm having a problem with model binding. When i debug with firebug, it shows options.models is undefined. Because of that reason the "if" condition in parrameterMap is always false and grid doesn't populate the data. But when i remove the parrameterMap part, it works. I think, it's very helpful if somebody can explain about the parameter map in kendo dataSource. Thank you.

    function GetDataSource() {
    var PrjKy = $("#cmbPrjNm").val();
    if (PrjKy == "") { PrjKy = 1; }

    var PrcsDetKy = 1;
    if (PrcsDetKy == "") { PrcsDetKy = 1; }

    var PrcsTypKy = $("#toDotype").val();
    if (PrcsTypKy == "") { PrcsTypKy = 1; }

    var AprPrtyKy = $("#cmbPiority").val();
    if (AprPrtyKy == "") { AprPrtyKy = 1; }

    var AprStsKy = $("#status").val();
    if (AprStsKy == "") { AprStsKy = 1; }

    var OrginAdrKy = 1;
    if (OrginAdrKy == "") { OrginAdrKy = 1; }

    var AprUsrKy = 1;
    if (AprUsrKy == "") { AprUsrKy = 1; }

    var NxtActByAdrKy = $("#cmbEmployee").val();
    if (NxtActByAdrKy == "") { NxtActByAdrKy = 1; }

    var FrmNxtActEntDt = $("#FrmNextActEnt").val();
    var ToNxtActEntDt = $("#ToNextActEnt").val();

    var FrmNxtActDt = $("#rcdDt").val();
    var ToNxtActDt = $("#toDt").val();

    var FrmInsertDt = $("#insrtDt").val();
    var ToInsertDt = $("#InsrtToDt").val();

    var dataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: '@Url.Content("~/User/GetAllToDo")',
                data: {
                    'PrjKy': PrjKy,
                    'PrcsDetKy': PrcsDetKy,
                    'PrcsTypKy': PrcsTypKy,
                    'AprPrtyKy': AprPrtyKy,
                    'AprStsKy': AprStsKy,
                    'OrginAdrKy': OrginAdrKy,
                    'AprUsrKy': AprUsrKy,
                    'NxtActByAdrKy': NxtActByAdrKy,
                    'FrmNxtActEntDt': FrmNxtActEntDt,
                    'ToNxtActEntDt': ToNxtActEntDt,
                    'FrmNxtActDt': FrmNxtActDt, //changed on 2013-8-30
                    'ToNxtActDt': ToNxtActDt, //changed on 2013-8-30
                    'FrmInsertDt': FrmInsertDt, //changed on 2013-8-30
                    'ToInsertDt': ToInsertDt//changed on 2013-8-30
                },
                dataType: "json"
            },
            update: {
                url: "~/Home/UpdateToDo",
                contentType: 'application/json; charset=utf-8',
                dataType: "json",
                type: "POST"
            },
            create: {
                url: '@Url.Content("~/Home/UpdateToDo")',
                contentType: 'application/json; charset=utf-8',
                dataType: "json",
                type: "POST"
            },
            destroy: {
                url: '@Url.Content("~/User/DeleteToDo")',
                contentType: 'application/json; charset=utf-8',
                dataType: "json",
                type: "POST"
            },
            parameterMap: function (options, operation) {
                if (operation !== "read" && options.models) {
                    return JSON.stringify({ models: options });
                }
            }
        },
        pageSize: 10
    , schema:
    {
        model:
        {
            id: "PrcsDetKy", //Primary key to uniquely identify the row.
            fields: //Relavent fields of the grid should be bind with following model items
                {
                ID: { editable: false, nullable: false },
                NxtActEntDt: { editable: true, nullable: false, validation: { required: true} },
                AprPrty: { editable: true, nullable: false, validation: { required: true} },
                AprUsr: { editable: true, nullable: true },
                AprSts: { editable: true, nullable: true },
                AprStsKy: { editable: true, nullable: true },
                AprPrtyKy: { editable: true, nullable: true },
                AprUsrKy: { editable: true, nullable: true },
                AprResnKy: { editable: true, nullable: true },
                PrjId: { editable: true, nullable: true },
                TaskId: { editable: true, nullable: true },
                TaskNm: { editable: true, nullable: false }, //validation: { required: true}
                PrcsDetKy: { editable: false, nullable: false },
                TaskTyp: { editable: true, nullable: false },
                PrcsTypKy: { editable: true, nullable: true },
                PrjKy: { editable: true, nullable: true },
                PrcsDetAprKy: { editable: true, nullable: true },
                PrjNm: { editable: true, nullable: false, validation: { required: true} },
                Des: { editable: true, nullable: false },
                NxtActByAdr: { editable: true, nullable: false, validation: { required: true} },
                NxtActByAdrKy: { editable: true, nullable: true },
                NxtActDt: { editable: true, nullable: true },
                Rem: { editable: true, nullable: true, type: "string" },
                OriginBy: { editable: false, nullable: true },
                Hyperlinks1: { editable: false, nullable: true },
                Hyperlinks2: { editable: false, nullable: true },
                Hyperlinks3: { editable: false, nullable: true },
                Hyperlinks4: { editable: false, nullable: true },
                OrginAdrKy: { editable: true, nullable: true },
                WrkStnKy: { editable: true, nullable: true },
                ObjKy: { editable: true, nullable: true },
                ObjCd: { editable: true, nullable: true },
                ObjNm: { editable: true, nullable: true },
                ItmKy: { editable: true, nullable: true },
                ItmCd: { editable: true, nullable: true },
                IsAct: { editable: true, nullable: true },
                IsApr: { editable: true, nullable: true },
                OrgEntDt: { editable: true, nullable: true }
            }
        }
    }
    });
    return dataSource;
}


推荐答案

你可以找到相当清楚的解释在这里 parameterMap

You can find quite clear explanation in here parameterMap

您应该使用parametrMap定义自定义参数集或在远程服务调用期间执行其他操作。基本上你在这里说,如果我正在阅读,更新或删除(这是你的代码片段中读取值的操作变量)我想将以下参数添加到我在transport中定义的方法。

You should use parametrMap to define custom set of parameters or perform additional operations during the call to remote service. Basically here you saying, if I am reading, updating or deleting (this is the operation variable of value "read" in your snippet) I want to add following parameter(s) to the methods I defined in "transport".

在您的情况下,您似乎没有定义options.models,这意味着您的数据源没有任何变量/集合模型。嗯,它不必。对我来说,你试图调用的read方法看起来并不需要任何参数,所以你可能只是从paramMap返回空字符串,或者根本没有这个配置部分。

In your case you didn't defined options.models so it seems, which means your datasource doesn't have any variable/collection models. Well it doesn't have to. To me it looks like the read method you trying to call doesn't really need any parameters so you might just return empty string from the paramMap or not to have this configuration section at all.

注意:您定义数据源的方式有点令人困惑,您在定义url时不应提供配置数据,例如。你正在获取网址的数据。请参阅本地与远程

NOTE: the way you defined the datasource is bit confusing, you should not provide the configuration "data" when you defined the "url", eg. you are getting the data of the url. See Local vs Remote.

这篇关于Kendo dataSource参数图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆