下拉字段选择/返回null kendo ui grid - mvc

时间:2015-07-13 06:10:33

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

我正在使用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"
                }
            }
        });
}

1 个答案:

答案 0 :(得分:1)

你有没有添加

 dataTextField: "name",
 dataValueField: "id"