How to update jstree node values without reload

前端 未结 6 2071
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-07 07:11

I have a jstree that I created with the following code:

$(\'#mytree\').jstree({\"core\": { \"data\" : value
                             , \"themes\" : { \"dots\         


        
相关标签:
6条回答
  • 2021-02-07 07:33

    You can refresh node by this

    $('#treeView').jstree(true).refresh_node("node_id_here")
    
    0 讨论(0)
  • 2021-02-07 07:34

    worked for me: $('#structureRows').jstree("destroy").empty();

    function CreateStructureTree(jsonData)
            {
                $('#structureRows').jstree("destroy").empty(); 
                $('#structureRows').jstree
                    ({
                        'core' : {
                            'data':
                                [
    
                                    jsonData,
                                    {
                                    'id' : 'node_2',
                                    'text' : 'Root node with options',
                                    'state' : { 'opened' : true, 'selected' : true },
                                    'children' : [ { 'text' : 'Child 1' }, 'Child 2']
                                    }
                                ]
    
                         }
                    });
    
                }
    
    0 讨论(0)
  • 2021-02-07 07:40

    I load data via an url, so my refresh part looks like:

    $('#groupTree').jstree(true).settings.core.data.url = get_group_url();
    
    0 讨论(0)
  • 2021-02-07 07:47

    What you need is not refresh() but redraw() thus the code is

    $('#mytree').jstree(true).settings.core.data = new_data;
    $('#mytree').jstree(true).redraw(true);
    

    You can find the functions in the jstree API.

    As per zmirc suggestion, in v3.1 use:

    $('#mytree').jstree(true).settings.core.data = new_data;
    $('#mytree').jstree(true).refresh();
    
    0 讨论(0)
  • 2021-02-07 07:53

    for deleting the node and reload tree

     $('#mytree').jstree(true).refresh();
    

    for those who need to redraw without restart the tree use

    jQuery('#data').jstree(true).refresh(true);
    
    0 讨论(0)
  • 2021-02-07 07:56

    $('#mytree').jstree(true).refresh(); is working, but in my case it causes thread leak. every refresh adds one more thread

    0 讨论(0)
提交回复
热议问题