以编程方式刷新Bootstrap Treeview [英] Refresh Bootstrap Treeview programmatically

查看:81
本文介绍了以编程方式刷新Bootstrap Treeview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绑定到json数组的Bootstrap树视图.

I have a Bootstrap tree view which binds to a json array..

 $('#tree').treeview({data: data,
           onNodeSelected: function(event, data) {

            $m.nodeSelected(event,data);
          }});

绑定到树视图的数组是..

And the array that binded to the treeview is..

var data = [
    {
      "text": "Parent1",
      "selectable": "false",
      "nodeType": "main",
      "nodes": [
        {
          "text": "Child1",
          "typeId": "aa2d4ea9-bfad-4a5b-8794-994e7e482808",
          "nodeType": "sub"
        },
        {
          "text": "Child2",
          "typeId": "e01bd0cb-c93b-40f9-be44-be67f20668aa",
          "nodeType": "sub"
        }
      ]
    },
    {
      "text": "Parent2",
      "selectable": "false",
      "nodeType": "main",
      "nodes": [
        {
          "text": "Child1",
          "typeId": "a0256aa3-b2ef-53d7-1270-a5029e7138ce",
          "nodeType": "sub"
        }
      ]
    }
  ]

这就是我需要的..

我需要添加一个新的子节点/从树视图数据源中删除现有的子节点并刷新它.

I need to add a new child node / remove a existing child node from the treeview datasource and refresh it.

我已经尝试过,但是找不到解决方法.

I've tried but unable to find a solution.

推荐答案

只需调用:

$('#tree').treeview({data: data,
     onNodeSelected: function(event, data) {
        $m.nodeSelected(event,data);
     }
});

再次

更改 data 变量后:

示例: https://jsfiddle.net/k8m911u9/1/

这篇关于以编程方式刷新Bootstrap Treeview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆