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

MASTER - CHILD TABLE RELATIONAL FIELD

Dear Sir,

I have SFDATAGRID with Master table and Child Table View. In Master table one field GUID is set relation with Child Table.

Now Requirement is while viewing Child Table, How Can I Hide the Relational Field GUID in view Child table? How Can I hide other fields of Child Table ?

Please reply me at the earliest.

Thanks
Deepak



3 Replies

JP Jagadeesan Pichaimuthu Syncfusion Team May 27, 2019 07:14 AM UTC

Hi Deepak, 
  
Thanks for using Syncfusion products. 
  
If you want to hide the particular column from the child grid, after setting the details view data source to the grid, you can use the DetailsViewDefinition property. Refer to the following snippet code, 
  
Code Snippet: 
// hide the column in the details view grid. 
this.sfDataGrid1.DetailsViewDefinitions[0].DataGrid.Columns["OrderID"].Visible = false; 
this.sfDataGrid1.DetailsViewDefinitions[0].DataGrid.Columns["ProductID"].Visible = false; 
  
  
If the column is AutoGenerated for the child grid, you can remove the column from being generated for the child grid by canceling the AutoGeneratingColumn event. See the link below, 
 
Let us know whether this helps also if you need any further assistance on this.  
 
Regards, 
Jagadeesan 



JI Jiwo replied to Jagadeesan Pichaimuthu January 20, 2022 08:54 AM UTC

Dear Sir


not working



VS Vijayarasan Sivanandham Syncfusion Team January 21, 2022 03:21 PM UTC

Hi Jiwo,

Your requirement can be achieved by disable the Visible property in GridColumnBase of SfDataGrid. The GridViewDefinition.DataGrid columns can be generated either automatically or manually like parent DataGrid.

 
1. Automatically generating columns 
            In this case GridViewDefinition.DataGrid column generated automatically. So, you can hide the column by disable the Visible property in AutoGeneratingColumn event in DetailsViewDataGrid. Please refer the below code snippet, 
this.sfDataGrid1.AutoGeneratingRelations += OnAutoGeneratingRelations;  
 
private void OnAutoGeneratingRelations(object sender, Syncfusion.WinForms.DataGrid.Events.AutoGeneratingRelationsEventArgs e) 
{ 
            e.GridViewDefinition.DataGrid.AutoGeneratingColumn += OnAutoGeneratingColumn; 
} 
 
private void OnAutoGeneratingColumn(object sender, AutoGeneratingColumnArgs e) 
{ 
            //check the field to hide in ChildTable 
            if (e.Column.MappingName == "ID") 
            { 
                //hide the ID column by disable Visible property in GridColumn 
                e.Column.Visible = false; 
            } 
} 
 

For more information related to Auto generating columns, please refer the below user guide documentation link,
 
 

2. Manually define columns

         
In this case GridViewDefinition.DataGrid columns are define in manually. So, you can hide the column by disable the Visible property in GridColumn. Please refer the below code snippet, 
this.sfDataGrid1.AutoGeneratingRelations += OnAutoGeneratingRelations;  
 
private void OnAutoGeneratingRelations(object sender, Syncfusion.WinForms.DataGrid.Events.AutoGeneratingRelationsEventArgs e) 
{ 
            //Manually define columns 
            e.GridViewDefinition.DataGrid.AutoGenerateColumns = false; 
            e.GridViewDefinition.DataGrid.Columns.Add(new GridTextColumn() { MappingName = "ID", HeaderText = "ID" ,Visible = false}); 
            e.GridViewDefinition.DataGrid.Columns.Add(new GridTextColumn() { MappingName = "Name", HeaderText = "Name" }); 
            e.GridViewDefinition.DataGrid.Columns.Add(new GridTextColumn() { MappingName = "City", HeaderText = "City" }); 
            e.GridViewDefinition.DataGrid.Columns.Add(new GridTextColumn() { MappingName = "Quantity", HeaderText = "Quantity" }); 
            e.GridViewDefinition.DataGrid.Columns.Add(new GridTextColumn() { MappingName = "UnitPrice", HeaderText = "Unit Price" }); 
} 
 

Sample Link:
https://www.syncfusion.com/downloads/support/forum/144849/ze/SfDataGridDemo-246908460

For more information related to Manually defining columns, please refer the below user guide documentation link,

UG Link:
https://help.syncfusion.com/windowsforms/datagrid/masterdetailsview#manually-defining-columns

Regards,
Vijayarasan S 


Loader.
Live Chat Icon For mobile
Up arrow icon