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

Adding template relationships

1 Answer 70 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Johan
Top achievements
Rank 1
Johan asked on 31 Mar 2008, 08:41 AM
I have an ConfigurationGroup object that contains ConfigurationGroupParameters. I want to display this in an hierarchic Grid. The relationship between the parameters and their configuration group is built dynamically as I receive data from my server.

Upon my first setParameters, the grid view displays my Groups as expandable, but no data is available when I try to expand them (and no sub grid appears). Upon my second receive I am able to display the parameter sub grid in my grid, but data is only available for the first Configuration group, the second, most recent set, group becomes empty.

I tried to do a work around by adding a dummy relationship with unique name after adding a parameter group. This made my data visible after the first receive. But on the second receive the m_GridView.Relations.Add() row throws an exception (Object set to null).

Is there something obvious missing in the code below, or is this a bug?

        public void SetConfigurationGroupParameters(ConfigurationGroup configurationGroup)  
        {  
            m_GridView.GridElement.BeginUpdate();  
 
            bool isNewConfigurationGroup = !m_ParameterBinder.ContainsKey(configurationGroup);
            #region Get Template  
            GridViewTemplate template = null;  
            if (isNewConfigurationGroup)  
            {  
                template = new GridViewTemplate(m_GridView);  
                template.AllowAddNewRow = false;  
                m_ParameterBinder.Add(configurationGroup, template);
                #region Create Columns  
                template.AutoGenerateColumns = false;  
                template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;  
                Collection<GridViewColumn> columns = CreateColumns(Presenter.GetParameterColumns());  
                foreach (GridViewColumn column in columns)  
                {  
                    template.Columns.Add(column);  
                }
                #endregion  
 
            }  
            template = m_ParameterBinder[configurationGroup];
            #endregion  
 
 
            if (configurationGroup.Parameters != null)  
            {  
                template.DataSource = configurationGroup.Parameters;
                
                #region Arrange Relationship  
                GridViewRelation relation = new GridViewRelation(m_GridView.MasterGridViewTemplate);  
                relation.RelationName = "ConfigurationGroupsParameters." + configurationGroup.ConfigurationGroupOId;  
                relation.ParentColumnNames.Add("ConfigurationGroupOId");  
                relation.ChildColumnNames.Add("ConfigurationGroupOId");  
                relation.ChildTemplate = template;  
                m_GridView.Relations.Add(relation);  
 
                m_GridView.MasterGridViewTemplate.ChildGridViewTemplates.Add(template);
                
                #endregion  
            }  
 
            m_GridView.GridElement.EndUpdate();  
        } 

1 Answer, 1 is accepted

Sort by
0
Vassil Petev
Telerik team
answered on 31 Mar 2008, 11:12 AM
Hello Johan,

Please try to add a relation after adding the GridViewTemplate object and also set the AutoGenerateHierachyFromDataSet property to false.
 
Currently, we have found some issues related to the binding mechanism in RadGridView in hierarchical mode. We have completely refactorred the hierarchical engine in the RadGridView. Please download and try our Q1 2008 Beta release, which features the greatly improved RadGridView. We would greatly appreciate your feedback on using the Beta.

You can download it from the link below:

<admin>link no longer valid</admin>

Contact me again if you have any further questions.

Sincerely yours,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Johan
Top achievements
Rank 1
Answers by
Vassil Petev
Telerik team
Share this question
or