gpt4 book ai didi

mvvm - 通过 mvvm 将复选框列表绑定(bind)到 kendo ui 中的下拉列表

转载 作者:行者123 更新时间:2023-12-03 10:24:02 25 4
gpt4 key购买 nike

很难说出这里问的是什么。这个问题是模棱两可的、模糊的、不完整的、过于宽泛的或修辞的,无法以目前的形式得到合理的回答。如需帮助澄清这个问题以便重新打开它,visit the help center .




9年前关闭。




我的 View 中有一个下拉列表我想要在我的 View 中。我想要在更改我的下拉列表时,一个 java 脚本模板绑定(bind)下拉列表。我写这个但不工作恳求帮助我。

  var  roles=[{
code:1,
roleName: "Admin",
access: [
{ id: 1, description: "create", selected: true},
{id: 2, description: "delete", selected: false},
{ id: 3, description: "update", selected: false}
]
} ,{
code:2,
roleName: "user",
access: [
{ id: 1, description: "create", selected: true},
{id: 2, description: "delete", selected: true},
{ id: 3, description: "update", selected: false}
]
}];
var viewModel = kendo.observable({
Roles:roles,
role:"Admin",
accessRole:null
});

kendo.bind($("#example"), viewModel);

这是我的 View 代码
<div id="example">
Current Role&nbsp;&nbsp;&nbsp;:<span data-bind="text: role"></span>
<br>
<select type="text" id="RoleName" data-bind="source: Roles, value:role" data-text-field="roleName">

<select/>

<ul data-template="row-template" data-bind="source: accessRole.access"></ul>

</div>

<script id="row-template" type="text/x-kendo-template">
<li>
<input type="checkbox" data-bind="checked: selected" />
<label data-bind="text: description" />
</li>
</script>


这是在线代码:
http://jsfiddle.net/shahr0oz/K4X3T/19/
​​​

最佳答案

我得到它。

<div id="example">
Current Role&nbsp;&nbsp;&nbsp;:<span data-bind="text: role.roleName"></span>
<br>
<select type="text" data-bind="source: Roles,value:role}" data-text-field="roleName">

<select/>

<ul data-template="row-template" data-bind="source:role.access"></ul>

</div>

<script id="row-template" type="text/x-kendo-template">
<li>
<input type="checkbox" data-bind="checked: selected" />
<label data-bind="text: description" />
</li>
</script>

​ var roles=[{
code:1,
roleName: "Admin",
access: [
{ id: 1, description: "create", selected: true},
{id: 2, description: "delete", selected: true},
{ id: 3, description: "update", selected: false}
]
} ,{
code:2,
roleName: "user",
access: [
{ id: 1, description: "create", selected: false},
{id: 2, description: "delete", selected: false},
{ id: 3, description: "update", selected: false}
]
}];
var viewModel = kendo.observable({
Roles:roles,
role:roles[0]
});


kendo.bind($("#example"), viewModel);

​​​
http://jsfiddle.net/shahr0oz/psEVy/

关于mvvm - 通过 mvvm 将复选框列表绑定(bind)到 kendo ui 中的下拉列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12770417/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com