如何使用RecordFilters过滤TreeViewAdv

7

我是C#和SyncFusion的新手,非常感谢您的帮助。

在过滤gridGroupingControl后,我需要在TreeViewPresenter(TreeViewAdv)中显示正确的记录。

起初,我考虑使用以下方式获取筛选器:

detailGroupingControl.TableDescriptor.RecordFilters

我想在 TreeViewPresenter 中设置这些过滤器,但似乎它并不起作用。有没有简单的方法使用与 gridGroupingControl 相同的过滤条件来过滤树形控件?

1个回答

3
如果你想将一个TreeView节点的RecordFilters添加到另一个TreeView节点中,你需要将表格对象添加到一个列表中。使用这个列表,过滤可以反映到所有的TreeView节点上。请参考下面的代码和示例。
//Used to save the objects of all grids
List<GridGroupingControl> grids = new List<GridGroupingControl>();

//add the grid to the list
grids.Add(GridGroupingControl);

void RecordFilters_Changed(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e)
{
    Syncfusion.Grouping.RecordFilterDescriptorCollection filters = sender as RecordFilterDescriptorCollection;
    foreach (GridGroupingControl grid in grids)
    {
        foreach(RecordFilterDescriptor filter in filters)
        {
            //To avoid the repeated objects from the list
            if (grid.TableDescriptor.RecordFilters.Contains(filter))
                continue;
            grid.TableDescriptor.RecordFilters.Add(filter);
        }
    }
}

你正在为网格设置过滤器,但我想要它们过滤我的树节点。树没有像 .TableDescriptor.RecordFilters.Add(filter) 这样的方法。目前,我只是在循环中将网格中的每一行放入我的树中。 - ninjaxelite

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接