我在列表视图中使用 Kendo UI 下拉列表
<ul data-role="listview" id="participants-listview" data-style="inset" data-template="participants-listview-template" data-bind="source: participants, events { click: onSelectParticipant }" />
<script type="text/x-kendo-template" id="listview-template">
<div>
<span>#:RoleDesc#</span>
<span>
<select data-role="dropdownlist" id="status-id"
data-text-field="StatusDesc"
data-value-field="StatusId"
data-bind="value: StatusId, source: participantStatuses, events: { change: onParticipantStatusChange }"
name="Status"
required="required"
validationMessage="required">
</select>
</span>
</div>
</script>
视图模型
viewModel = kendo.data.ObservableObject.extend({
dataSource: new kendo.data.DataSource({
transport: {
type: "odata",
read: {
url: function() {
return meetings/participants";
}
}
}
}),
participants: [], //listview data
participantStatuses: [ // dropdownlist selection
{ StatusId: 1, StatusDesc: "Invited" } ,
{ StatusId: 6, StatusDesc: "Present" },
{ StatusId: 7, StatusDesc: "Absent" }
],
selectedParticipant: null,
showListView: function(e) {
viewModel.dataSource.fetch(function(){
var data = viewModel.dataSource.data();
meetingViewModel.set("participants", data);
});
},
我期望当页面加载时,参与者的选定 statusId 将被下拉列表捕获为 selectedValue,方法是将参与者绑定StatusId
到下拉列表的value
属性,如下所示data-bind="value:StatusId"
。但在我的情况下它很奇怪,它抛出了一个错误
Uncaught TypeError: Object #<Object> has no method 'get'
当我删除 时data-bind="value:StatusId"
,错误消失了,但它没有选择适当的选定值。
关于这个错误的任何想法?