jeudi 5 novembre 2015

How to default checked checkbox in JSON data

Using jsTree with checkbox and state plugin, each time I check some checkboxes and reload page they are still checked. How is possible to use state plugin with checkboxes, but “forget” checkbox state (leaving opened and selected node state as is).and How to default checked checkbox in JSON data

[{"id":"1","state":{"selected":true},"text":"\u90e8\u95e8\u7ba1\u7406","parent":"#"},{"id":"2","state":{"selected":true},"text":"\u89d2\u8272\u7ba1\u7406","parent":"#"},{"id":"3","state":{"selected":true},"text":"\u4eba\u5458\u7ba1\u7406","parent":"#"},{"id":"4","state":{"selected":false},"text":"\u6743\u9650\u7ba1\u7406","parent":"#"},{"id":"6","state":{"selected":false},"text":"\u589e\u52a0\u6743\u9650","parent":"4"}\]]

js:

$('#module_jstree').jstree({
            'core' : {
                "check_callback":true,
                'cache':false,
                'data' : {
                    'url' :"<?php echo base_url();?>module_controller/get_role_permission_by_json/<?=$role_id; ?>",
                    "dataType" : "json"
                },
                state:{
                  "key":"module_jstree"
                },
                'themes' : {
                    'responsive' : false
                }
            },
            'checkbox':{
                'keep_selected_style':false
            },
            'plugins' : ['state','checkbox']
        });

Aucun commentaire:

Enregistrer un commentaire