【问题标题】:kendo ui update grid with dropdownlistkendo ui 使用下拉列表更新网格
【发布时间】:2013-01-01 10:30:39
【问题描述】:

我在更新 kendo ui 网格时遇到问题。
我创建这样的网格: http://demos.kendoui.com/web/grid/editing-custom.html, 但我也添加了更新功能。

我的问题在下一个。

更新网格后,更新请求正常(POST url 200 OK),但之后我在浏览器控制台中收到错误:

TypeError: Distribution is undefined.

分布是下拉列表中的数据类型。

这是我的代码:

dataSource:
...
update: {    
    url: "/Modeling/EditCurrentStates",
    type: "POST"
}
...
schema: {
    model: {
        id: "StateNumber",
        fields: {
            ...
            Distribution: { defaultValue: { Id: 1, Name: "Exponential"}
            ...

columns: [
    ...
    { 
        field: "Distribution", 
        title: "Distribution", 
        editor: distributionDropDownEditor, 
        template: "#=Distribution.Name#" 
    },

    function distributionDropDownEditor(container, options) {
        $('<input data-text-field="Name" data-value-field="Id" data-bind="value:' + options.field + '"/>')
            .appendTo(container)
            .kendoDropDownList({
                autoBind: false,
                dataSource: {
                    type: "json",
                    transport: {
                        read: "/Modeling/GetDistributions"
                    }
                }
            });
    }

【问题讨论】:

    标签: kendo-ui


    【解决方案1】:

    您没有定义您的数据从哪里传到剑道。你需要exe

    数据:“数据”

    dataSource:
    ...
    update: {    
        url: "/Modeling/EditCurrentStates",
        type: "POST"
    }
    
    ...
    schema: {
        data: "data",
        model: {
            id: "StateNumber",
            fields: {
                ...
                Distribution: { defaultValue: { Id: 1, Name: "Exponential"}
                ...
    
    columns: [
        ...
        { 
            field: "Distribution", 
            title: "Розподіл", 
            editor: distributionDropDownEditor, 
            template: "#=Distribution.Name#" 
        },
    
    function distributionDropDownEditor(container, options) {
        $('<input data-text-field="Name" data-value-field="Id" data-bind="value:' + options.field + '"/>')
            .appendTo(container)
            .kendoDropDownList({
                autoBind: false,
                dataSource: {
                    type: "json",
                    transport: {
                        read: "/Modeling/GetDistributions"
                    }
                }
            });
    }
    

    【讨论】:

      猜你喜欢
      • 2015-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多