We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Reolad Data in gird grouping control

Hi all
I have a gridgrouping control that load the data with code taken from your site (see below) and it works fine.
In the code I setup also some filter , hide some colums, set some other columns to read only  ecc.

Now I need to reload the data , how is possibile to achieve this and maintain the setup of grid ?
Thank you for yor support

Franco

DataTable parentTable = GetParentTable();
DataTable childTable = GetChildTable();
DataTable grandChildTable = GetGrandChildTable();
GridRelationDescriptor parentToChildRelationDescriptor = new GridRelationDescriptor();

//Same as SourceListSetEntry.Name for Child Table.
parentToChildRelationDescriptor.ChildTableName = "MyChildTable";
parentToChildRelationDescriptor.RelationKind = RelationKind.RelatedMasterDetails;
parentToChildRelationDescriptor.RelationKeys.Add("parentID", "ParentID");

//Adds relation to Parent Table.
gridGroupingControl1.TableDescriptor.Relations.Add(parentToChildRelationDescriptor);
GridRelationDescriptor childToGrandChildRelationDescriptor = new GridRelationDescriptor();

//Same as SourceListSetEntry.Name for Grand Child Table.
childToGrandChildRelationDescriptor.ChildTableName = "MyGrandChildTable";
childToGrandChildRelationDescriptor.RelationKind = RelationKind.RelatedMasterDetails;
childToGrandChildRelationDescriptor.RelationKeys.Add("childID", "ChildID");

//Adds relation to Child Table.
parentToChildRelationDescriptor.ChildTableDescriptor.Relations.Add(childToGrandChildRelationDescriptor);
this.gridGroupingControl1.Engine.SourceListSet.Add("MyParentTable", parentTable);
this.gridGroupingControl1.Engine.SourceListSet.Add("MyChildTable", childTable);
this.gridGroupingControl1.Engine.SourceListSet.Add("MyGrandChildTable", grandChildTable);

this.gridGroupingControl1.DataSource = parentTable;


3 Replies

AR Arulpriya Ramalingam Syncfusion Team June 5, 2017 01:41 PM UTC

Hi franco, 

Thanks for using Syncfusion products. 

In GridGroupingControl, If you want the grid settings while reloading the GridGroupingControl, you need to create the separate methods for Grid(GridSettings) then use this method when reload the grid. Please refer the below code and sample, 

Code snippet 
 
public Form1() 
{ 
    InitializeComponent(); 
 
    // DataSource code// 
    
      this.GridSettings(); 
} 
 
#region Grid Settings 
public void GridSettings() 
{ 
    gridGroupingControl1.AllowProportionalColumnSizing = true; 
    //Setting the filter condition. 
    FilterCondition condition = new FilterCondition(FilterCompareOperator.GreaterThan, 50); 
    //Setting the RecordFilterDescriptor 
    RecordFilterDescriptor recordFilterDescriptor = new RecordFilterDescriptor("CategoryID", condition); 
    //Adding the RecordFilterDescriptor to collection 
    this.gridGroupingControl1.TableDescriptor.RecordFilters.Add(recordFilterDescriptor); 
   //To add the hidden columns 
    foreach (GridColumnDescriptor col in this.gridGroupingControl1.TableDescriptor.Columns) 
    { 
        if (!this.gridGroupingControl1.TableDescriptor.VisibleColumns.Contains(new GridVisibleColumnDescriptor(col.Name))) 
        { 
            this.gridGroupingControl1.TableDescriptor.VisibleColumns.Add(col.Name); 
        } 
    } 
} 
#endregion 
 
//Button click Event Customization 
private void reloadBtn_Click(object sender, EventArgs e) 
{ 
    this.gridGroupingControl1.DataSource = null; 
    this.gridGroupingControl1.DataSource = parentTable; 
    this.GridSettings(); 
} 
 
 
Regards, 
Arulpriya


FP franco perduca June 6, 2017 07:46 PM UTC

Thank You for your support
Another question 

it's possible to have a filter that work only in parent grid and not in a child ? like this