Suhail Mumtaz Awan
Suhail Mumtaz Awan

Reputation: 3483

Dropdown field select/returns null kendo ui grid - mvc

I am working on kendo ui grid, the dropdown fills with the data from api call..... The problem is,

selected item value is not passing to viewModel or passing null value

I am doing something terrible, please help...thanks for your time:)

Script

...
    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"
                }
            }
        });
}

Upvotes: 0

Views: 912

Answers (1)

LittleDragon
LittleDragon

Reputation: 2437

have you add the

 dataTextField: "name",
 dataValueField: "id"

?

Upvotes: 1

Related Questions