How to duplicate contents of two GridGroupingControl grids

I'm trying to find a solution which enables me to have a small (smaller in height) grid on one form, and a large (in height) version of the same grid on another form, with synchronization between them - i.e. when a filter or sort happens on the smaller grid, i want that to propagate to the larger grid.

How can I achieve this behavior?

1 Reply

MG Mohanraj Gunasekaran Syncfusion Team December 6, 2017 12:56 PM UTC

 Hi David, 

Thanks for using Syncfusion product. 

By default, GridGroupingControl does have the support to synchronize the cell values when bind the same datasource for both grids. Currently, GridGroupingControl does not have the direct support to synchronize two grids with filtering, Sorting, (etc) support. But, you can achieve your scenario by SortedColumnsChanged and FilterBarSelectedItemChanged event customization. We have prepared the sample based on your requirement. Please refer the below code example and the sample, 

Code example 
this.gridGroupingControl1.TableDescriptor.SortedColumns.Changed += SortedColumns_Changed; 
this.gridGroupingControl1.FilterBarSelectedItemChanged += gridGroupingControl1_FilterBarSelectedItemChanged; 
 
void gridGroupingControl1_FilterBarSelectedItemChanged(object sender, FilterBarSelectedItemChangedEventArgs e) 
{ 
    this.gridGroupingControl2.TableDescriptor.RecordFilters.Clear(); 
    if (this.gridGroupingControl1.TableDescriptor.RecordFilters.Count > 0) 
    { 
        foreach (RecordFilterDescriptor filter in this.gridGroupingControl1.TableDescriptor.RecordFilters) 
            this.gridGroupingControl2.TableDescriptor.RecordFilters.Add(filter); 
    } 
} 
 
void SortedColumns_Changed(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e) 
{ 
    if (e.Action == Syncfusion.Collections.ListPropertyChangedType.Refresh) 
    { 
        if (this.gridGroupingControl1.TableDescriptor.SortedColumns.Count > this.gridGroupingControl2.TableDescriptor.SortedColumns.Count) 
        { 
            foreach (SortColumnDescriptor column in this.gridGroupingControl1.TableDescriptor.SortedColumns) 
            { 
                if (!this.gridGroupingControl2.TableDescriptor.SortedColumns.Contains(column)) 
                    this.gridGroupingControl2.TableDescriptor.SortedColumns.Add(column); 
            } 
        } 
        else 
        { 
            this.gridGroupingControl2.TableDescriptor.SortedColumns.Clear(); 
            foreach (SortColumnDescriptor column in this.gridGroupingControl1.TableDescriptor.SortedColumns) 
            { 
                if (!this.gridGroupingControl2.TableDescriptor.SortedColumns.Contains(column)) 
                    this.gridGroupingControl2.TableDescriptor.SortedColumns.Add(column); 
            } 
        } 
    } 
 
    SortColumnDescriptor scd = e.Item as SortColumnDescriptor; 
    if (scd == null) 
        return; 
    if (e.Action == Syncfusion.Collections.ListPropertyChangedType.Add) 
    { 
        this.gridGroupingControl2.TableDescriptor.SortedColumns.Add(scd); 
    } 
    else if (e.Action == Syncfusion.Collections.ListPropertyChangedType.Remove) 
    { 
        if (this.gridGroupingControl2.TableDescriptor.SortedColumns.Contains(scd)) 
            this.gridGroupingControl2.TableDescriptor.SortedColumns.Remove((scd)); 
    } 
} 
 


Sample link: GridGroupingControl 

Note: 
If you want to synchronize the other functionalities for grids. You should manually implement that actions by event customization. 

Please let us know if you have any concerns 

Regards, 
Mohanraj G 
 


Loader.
Up arrow icon