Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用jquery删除treeview子节点_Javascript_Jquery_Asp.net Mvc_Asp.net Mvc 3 - Fatal编程技术网

Javascript 如何使用jquery删除treeview子节点

Javascript 如何使用jquery删除treeview子节点,javascript,jquery,asp.net-mvc,asp.net-mvc-3,Javascript,Jquery,Asp.net Mvc,Asp.net Mvc 3,我有一个树状视图,如下所示,我需要根据用户从列表中删除一个子项。谁能告诉我怎么把孩子从树上移开吗 var treedata = [ { label: 'Floor', type: 'Country', children: [ { label: 'Bangalore', type: 'Location',

我有一个树状视图,如下所示,我需要根据用户从列表中删除一个子项。谁能告诉我怎么把孩子从树上移开吗

var treedata = [

           {
               label: 'Floor', type: 'Country',
               children: [
                   {
                       label: 'Bangalore', type: 'Location',
                       children: [{ label: 'Technopolis', type: 'facility', id: 1 }, { label: 'Ecity Tower-2', type: 'facility', id: 2 }, { label: 'Bagmane', type: 'facility', id: 3 }, { label: 'Cyber Park', type: 'facility', id: 4 }]
                   },
                   {
                       label: 'Hyderabad', type: 'Location',
                       children: [{ label: 'Hitech City ', type: 'facility', id: 5 }, { label: 'Cyber City', type: 'facility', id: 6 }]
                   },
                   {
                       label: 'Chennai', type: 'Location',
                       children: [{ label: 'XXX', type: 'facility', id: 7 }]
                   },
                   {
                       label: 'Mumbai', type: 'facility', id: 8
                   }
               ]
           },
             {
                 label: 'Role Administration', type: 'Role',
                 children: [{ label: 'Assign Role', type: 'Role', id: 1 }]
             },

{
    label: 'Hoteling Admin', type: 'Hoteling',
    children: [{ label: 'Hoteling', type: 'Hoteling', id: 1 }]
}


];
上面是我的jquery树数据。如果用户是普通用户,我想通过检查用户角色来删除角色管理

任何人都可以帮助我如何使用jquery

谢谢

您可以使用
$.grep()
根据需要的任何条件将数组筛选为新数组

var userRole='normal';
if( userRole === 'normal'){    
    treeview = $.grep(treeview, function(item){
         return item.label != 'Role Administration';
    });    
}

用户角色节点在哪里?