Grid View Hierarchy Not Expanding

8 posts, 0 answers
  1. Mike
    Mike avatar
    4 posts
    Member since:
    May 2010

    Posted 19 Jul 2010 Link to this post

    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 { }
            }

  2. Mike
    Mike avatar
    4 posts
    Member since:
    May 2010

    Posted 19 Jul 2010 Link to this post

    Hi Telerik Team,

    Can you please provide me with a remedy ?

    Many Thanks
  3. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 22 Jul 2010 Link to this post

    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
  4. kapil
    kapil avatar
    1 posts
    Member since:
    Jun 2009

    Posted 06 Sep 2010 Link to this post

    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.
  5. Vassil Petev
    Admin
    Vassil Petev avatar
    1765 posts

    Posted 07 Sep 2010 Link to this post

    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
  6. John
    John avatar
    28 posts
    Member since:
    Sep 2013

    Posted 09 Dec 2014 Link to this post

    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
  7. John
    John avatar
    28 posts
    Member since:
    Sep 2013

    Posted 09 Dec 2014 in reply to John Link to this post

    I am using version 2014.1.402.40
  8. Ivan Petrov
    Admin
    Ivan Petrov avatar
    705 posts

    Posted 12 Dec 2014 Link to this post

    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.

     
Back to Top