2015-07-13 48 views
0

我工作的劍道UI格,下拉與API調用的數據填充..... 的問題是,下拉字段選擇/返回null劍道UI格 - MVC

所選項目的值不傳遞給視圖模型或傳遞null值

我做什麼可怕的事情,請大家幫幫忙...感謝您的時間:)

腳本

... 
    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

有你添加

dataTextField: "name", 
dataValueField: "id" 

+0

謝謝你的回覆,不,我沒有添加它,因爲dataTextField給出錯誤,DataValueField不工作.. –