mardi 1 novembre 2016

How to checked in jstree from a dynamic data?

I use Jstree at http://ift.tt/On4rlE, I've loaded tree struct succcess, and now i want to bind checked checkbox from a array data. Default, the nodes with one id, I will check id of node in a array, if same, the checkbox is checked. This is code snippet

    $('#jstree_demo_div').jstree({
                'core': {
                    'data':
                        [
                            { "id": "A1", "parent": "#", "text": "Simple root node" },
                            { "id": "A2", "parent": "#", "text": "Root node 2" },
                            { "id": "A3", "parent": "A2", "text": "Child 1" },
                            { "id": "A4", "parent": "A2", "text": "Child 2" },
                            { "id": "A5", "parent": "A1", "text": "Root Child 1" },
                            { "id": "A6", "parent": "A1", "text": "Root Child 2" },
                            { "id": "A7", "parent": "A5", "text": "Sub 1" },
                            { "id": "A8", "parent": "A5", "text": "Sub 2" }
                        ]
                },
                "plugins": ["checkbox"]
            });

  $(window).load(function () {
             var array_node = ['A3','A4','A8'];
                for (var i = 0; i < array_node.length; i++) {
                    $('#jstree_demo_div').jstree("select_node", array_node[i]);
                }
            });   

Seem it's not working although not error occurs




Aucun commentaire:

Enregistrer un commentaire