我的页面中有一个下拉列表,这是代码:
<div id="test">
Role: <span data-bind="text: role"></span>
</br>
Roles:<select id="roles" data-bind="source: roles, value: role" data-text-field="roleName" data-value-field="roleId" ></select>
<ul id="view" data-template="Access-template" data-role="listview" data-bind="source:Accesses"></ul>
<script id="Access-template" type="text/x-kendo-template">
<li>
<input type="checkbox" data-bind="checked: selected" />
<label data-bind="text: AccessName" />
</li>
</script>
</div>
我希望当我更改下拉列表值时,它会更改我的角色集合。这是我的代码:
var Accesses = [{
AccessName: 'Create',
selected: false
}, {
AccessName: 'Delete',
selected: false
}, {
AccessName: 'Update',
selected: true
}];
var Roles = [{
roleName: "Admin",
roleId: 1,
accessItem: Accesses
}, {
roleName: "User",
roleId: 2,
accessItem: Accesses
}];
var viewModel = kendo.observable({
roles: Roles,
accssesItem: Roles.accessItem
});
kendo.bind($("#test"), viewModel);