This is a migrated thread and some comments may be shown as answers.

Grid View Hierarchy Not Expanding

7 Answers 176 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 19 Jul 2010, 08:39 AM
Hi,

I'm using the winforms Telerik GridView in c#

I'm trying to populate a Parent Child Relationship ( Self Referencing Columns from same Table). I have created the Master and Child Templates. Code Below.

On executing this code, the master files are displayed with a '+' symbol. However they dont seem to be expandable. But when the bound columns are removed from the child template, the hierarchy works fine (Child data are displayed)

Also when for the child template, Columns are NOT customised and AUTOGENERATECOLUMNS is set to true, the hierarchy works fine and child data is displayed.

Can you please suggest how to achieve a hierarchy with customised bound columns in the Child template like in the case below ? I need this at the earliest as i'm running on a deadline

 

 

 

// Datasource for Parent Rows
  
DataTable dtDashboardView_MasterFiles = CDashboardManager.Get_DashboardView_MasterFiles();
  
// Datasource for Child Rows
  
DataTable dtDashboardView_SubFiles = CDashboardManager.Get_DashboardView_SubFiles();
  
// Parent Template Creation
  
radDashboard.AutoGenerateHierarchy = true ;
radDashboard.MasterGridViewTemplate.AutoExpandGroups = true;
radDashboard.MasterGridViewTemplate.AutoGenerateColumns = false;
radDashboard.EnableAlternatingRowColor = true;
((GridTableElement)radDashboard.GridElement).AlternatingRowColor = Color.LightGray;
radDashboard.MasterGridViewInfo.TableHeaderRow.AllowResize = true;
radDashboard.MasterGridViewTemplate.AllowAddNewRow = false;
radDashboard.MasterGridViewTemplate.AllowDeleteRow = false;
radDashboard.MasterGridViewTemplate.AllowEditRow = true;
PopulateMasterGridColumns();
radDashboard.MasterGridViewTemplate.DataSource = dtDashboardView_MasterFiles;
  
// Child Template Creation
  
GridViewTemplate template = new GridViewTemplate();
template.Caption = "SubFiles";
template.AutoGenerateColumns = false;
template.AllowColumnResize = true;
template.AllowRowResize = false;
template.AllowAddNewRow = false;
template.AllowDeleteRow = false;
template.AllowEditRow = true;
template.ShowColumnHeaders = true;
  
GridViewCheckBoxColumn dtCheckBox = new GridViewCheckBoxColumn();
dtCheckBox.UniqueName = "c_chkBxSelect";
dtCheckBox.HeaderText = "";
dtCheckBox.Width = 40;
template.Columns.Add(dtCheckBox);
  
GridViewTextBoxColumn cMasterID = new GridViewTextBoxColumn();
cMasterID.UniqueName = "c_MASTERID";
cMasterID.HeaderText = "Master ID";
cMasterID.FieldName = "MASTERID";
cMasterID.ReadOnly = true;
cMasterID.Width = 60;
template.Columns.Add(cMasterID);
  
GridViewTextBoxColumn cHealthStatus = new GridViewTextBoxColumn();
cHealthStatus.UniqueName = "c_HEALTHSTATUS";
cHealthStatus.HeaderText = "Health Status";
cHealthStatus.FieldName = "HEALTHSTATUS";
cHealthStatus.ReadOnly = true;
cHealthStatus.Width = 60;
template.Columns.Add(cHealthStatus);
  
  
radDashboard.MasterGridViewTemplate.ChildGridViewTemplates.Add(template);
  
// Establishing Relationship
                GridViewRelation relation = new GridViewRelation(radDashboard.MasterGridViewTemplate);
                relation.ChildTemplate = template;
                relation.RelationName = "MasterSub";
                relation.ParentColumnNames.Add("MASTERID");
                relation.ChildColumnNames.Add("c_MASTERID");
                radDashboard.Relations.Add(relation);
  
private void PopulateMasterGridColumns()
        {
            try
            {
                radDashboard.Columns.Clear();
  
                GridViewCheckBoxColumn dtCheckBox = new GridViewCheckBoxColumn();
                dtCheckBox.UniqueName = "chkBxSelect";
                dtCheckBox.HeaderText = "";
                radDashboard.MasterGridViewTemplate.Columns.Add(dtCheckBox);
                dtCheckBox.Width = 40;
  
                GridViewTextBoxColumn cMasterID = new GridViewTextBoxColumn();
                cMasterID.UniqueName = "MASTERID";
                cMasterID.HeaderText = "Master ID";
                cMasterID.FieldName = "MASTERID";
                cMasterID.ReadOnly = true;
                radDashboard.MasterGridViewTemplate.Columns.Add(cMasterID);
                cMasterID.Width = 60;
  
                GridViewTextBoxColumn cHealthStatus = new GridViewTextBoxColumn();
                cHealthStatus.UniqueName = "HEALTHSTATUS";
                cHealthStatus.HeaderText = "Health Status";
                cHealthStatus.FieldName = "HEALTHSTATUS";
                cHealthStatus.ReadOnly = true;
                radDashboard.MasterGridViewTemplate.Columns.Add(cHealthStatus);
                cHealthStatus.Width = 60;
  
                GridViewTextBoxColumn cBranch = new GridViewTextBoxColumn();
                cBranch.UniqueName = "BRANCH";
                cBranch.FieldName = "BRANCH";
                cBranch.ReadOnly = true;
                cBranch.HeaderText = "Branch";
                radDashboard.MasterGridViewTemplate.Columns.Add(cBranch);
                cBranch.Width = 70;
  
                GridViewTextBoxColumn cDepartment = new GridViewTextBoxColumn();
                cDepartment.UniqueName = "DEPARTMENT";
                cDepartment.FieldName = "DEPARTMENT";
                cDepartment.ReadOnly = true;
                cDepartment.HeaderText = "Dept";
                radDashboard.MasterGridViewTemplate.Columns.Add(cDepartment);
                cDepartment.Width = 40;
  
                GridViewTextBoxColumn cEditLink = new GridViewTextBoxColumn();
                cEditLink.UniqueName = "JOBFILENUMBER";
                cEditLink.FieldName = "JOBFILENUMBER";
                cEditLink.HeaderText = "Job File";
                radDashboard.MasterGridViewTemplate.Columns.Add(cEditLink);
                cEditLink.ReadOnly = true;
                cEditLink.Width = 70;
  
                GridViewTextBoxColumn cCustomerName = new GridViewTextBoxColumn();
                cCustomerName.FieldName = "CUSTOMER_NAME";
                cCustomerName.UniqueName = "CUSTOMERNAME";
                cCustomerName.HeaderText = "Customer Name";
                cCustomerName.ReadOnly = true;
                radDashboard.MasterGridViewTemplate.Columns.Add(cCustomerName);
                cCustomerName.Width = 180;               
            }
            catch (Exception pobjExc)
            {
                MessageBox.Show(pobjExc.Message.ToString());
                throw pobjExc;
            }
            finally { }
        }

7 Answers, 1 is accepted

Sort by
0
Mike
Top achievements
Rank 1
answered on 20 Jul 2010, 02:27 AM
Hi Telerik Team,

Can you please provide me with a remedy ?

Many Thanks
0
Jack
Telerik team
answered on 22 Jul 2010, 12:23 PM
Hi Mike,

When building self referencing hierarchy you should not add a child template. You have to add only one relation that relates to MasterTemplate. Please refer to the Folder tree example in our demo application for more information. I hope this helps.
 

All the best,
Jack
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
kapil
Top achievements
Rank 1
answered on 06 Sep 2010, 10:19 AM
Hi,

how to show the hierarchy based on some condition. I want to call a proc on clicking +sign, which will take the value from the row and populate the hierarchy child grid.
0
Vassil Petev
Telerik team
answered on 07 Sep 2010, 09:27 AM
Hi kapil,

Please, review the documentation on how to populate the grid in hierarchy mode. If you still experience problems, please open a new support ticket, because the current Forum thread relates to another problem.
 

Kind regards,
Vassil
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
John
Top achievements
Rank 1
answered on 09 Dec 2014, 06:54 PM
Hi,

I am not able to generating a hierarchical view when AutoGenerateColumns = False for the child template.  When AutogenerateColumns = True the hierarchy displays fine.  Also if I add two child templates with the same datasource, one with AGC=True and one with AGC=False they both are displayed (in a tabbed dropdown - nice feature btw).  I even tried adding two templates and then removing the AGC=True one but no dropdown was displayed.  How can I show the AGC=False dataset without showing the AGC=True one as well. OR as a workaround how can I hide the AGC = True template in the hierarchy.

Thanks,

John Klein
0
John
Top achievements
Rank 1
answered on 09 Dec 2014, 06:56 PM
I am using version 2014.1.402.40
0
Ivan Petrov
Telerik team
answered on 12 Dec 2014, 12:45 PM
Hello John,

Thank you for writing.

When AutoGenerateColumns is false you should add the desired columns manually to the template. Alternatively you can leave AutoGenerateColumns to true and hide the columns you do not want to see.

The best way to give you an adequate response is if you open a support ticket and send your project or a sample where the behavior is reproduced. This will allow us to give you a precise response exactly targeting your case.

Regards,
Ivan Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Mike
Top achievements
Rank 1
Answers by
Mike
Top achievements
Rank 1
Jack
Telerik team
kapil
Top achievements
Rank 1
Vassil Petev
Telerik team
John
Top achievements
Rank 1
Ivan Petrov
Telerik team
Share this question
or