1

ビューにドロップダウンリストがあります。ドロップダウンリストを変更するときに、Javaスクリプトテンプレートバインドドロップダウンリストが必要です。これを記述しますが、動作しないでください。

  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);

これは私のビューコード

<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/ < / p>

4

1 に答える 1

3

わかった。

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

于 2012-10-10T19:36:53.477 に答える