【问题标题】:Dropdown field select/returns null kendo ui grid - mvc下拉字段选择/返回 null kendo ui 网格 - mvc
【发布时间】:2015-07-13 06:10:32
【问题描述】:

我正在处理 kendo ui 网格,下拉列表中填充了来自 api 调用的数据..... 问题是,

所选项目值未传递给 viewModel 或传递空值

我正在做一些可怕的事情,请帮助...感谢您的时间:)

脚本

...
    schema: {
        model: {
            id: "ProjectId",
            fields: {
                ProjectId: { editable: true, nullable: false, type: "number" },
                ClientId: { editable: true, nullable: false, type: "number" },
                Name: { editable: true, nullable: true, type: "string" },
               // Status: { editable: true, nullable: true, type: "string" },
               Status: { editable: true, nullable: true, type: "string", defaultValue: { StatusId: "NotCompleted"}},
               IsActive: { editable: true, nullable: false, type: "boolean" },
            }
        }
    }
});

$("#grid").kendoGrid({
    dataSource: dataSource,
    pageable: true,
    toolbar: ["create"],
    scrollable: false,
    sortable: true,
    groupable: true,
    filterable: true,
    columns: [
        { field: "Name", title: "Project Name", width: "170px" },
        //{ field: "Status", title: "Status", width: "110px" },
         { field: "Status", title: "Status", width: "150px", editor: statusDropDownEditor },
        { field: "IsActive", title: "Active", width: "50px" },
        { command: "", template: "<a href='Project/Task'>Manage Task</a>", width: "30px", filterable: false },
        { command: "", template: "<a href='Project/Setting'>Setting</a>", width: "30px", filterable: false },
        { command: ["edit", "delete"], title: "&nbsp;", width: "80px" }
    ],
    editable: "popup"
});

function statusDropDownEditor(container, options) {
    $('<input required data-value-field="StatusID" data-bind="value:' + options.field + '"/>')
        .appendTo(container)
        .kendoDropDownList({
            autoBind: false,
            dataSource: {
                type: "odata",
                transport: {
                    read: "/api/dropdown/GetProjectStatus"
                }
            }
        });
}

【问题讨论】:

    标签: javascript kendo-ui kendo-grid kendo-asp.net-mvc


    【解决方案1】:

    你添加了吗

     dataTextField: "name",
     dataValueField: "id"
    

    ?

    【讨论】:

    • 感谢您的回复,不,我没有添加它,因为 dataTextField 给出错误并且 DataValueField 不起作用..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多