有没有办法隐藏树网格中的节点(父节点或子节点)?我将可见属性设置为 false,但它不会消失:(这里是小提琴链接:https://fiddle.sencha.com/#fiddle/jl1)
var tree = Ext.create('Ext.tree.Panel', {
renderTo: Ext.getBody(),
title: 'TreeGrid',
width: 300,
height: 250,
fields: ['name', 'description'],
columns: [{
xtype: 'treecolumn',
text: 'Name',
dataIndex: 'name',
width: 150,
sortable: true
}, {
text: 'Description',
dataIndex: 'description',
flex: 1,
sortable: true
}],
root: {
expanded: true,
children: [{
name: 'Group 1',
expanded: true,
children: [{
name: 'Child 1.1',
description: 'Description 1.1',
leaf: true
},{
name: 'Child 1.2',
description: 'Description 1.2',
leaf: true
}]
}, {
name: 'Group 2',
expanded: true,
children: [{
name: 'Child 2.1',
description: 'Description 2.1',
leaf: true
},{
name: 'Child 2.2',
description: 'Description 2.2',
leaf: true
}]
}]
}
});
var button = Ext.create('Ext.button.Button', {
renderTo: Ext.getBody(),
text: 'Remove group 1',
handler: function() {
var group1 = tree.getRootNode().childNodes[0];
group1.set('visible', false);
}
});
注意:我不想删除节点,我想隐藏它,以便稍后再次显示它(我想这样做是因为树网格上的删除/添加行为非常错误:S)!
提前感谢:)!
你应该使用树存储。使用筛选器隐藏树中的值。
我已经修好了你的小提琴。https://fiddle.sencha.com/#fiddle/jl8我用filterBy
方法修复它。如果函数返回 true,则记录将包含在树中,否则将被过滤掉。
以下是有关该主题的更多文档 http://docs.sencha.com/extjs/5.1/5.1.0-apidocs/#!/api/Ext.data.TreeStore