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

Combo Box in Hierarchy GridView

1 Answer 108 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sakthi
Top achievements
Rank 1
Sakthi asked on 23 Jul 2010, 01:41 PM
Hi,

I have implemented Hierarchy gridview. while clicking "+" sysmbol in the gridview row it will display childviewTemplate with related to the parent row. Currently I have two rows in my child table. So it is displaying those rows in the childviewTemplate. In the Last row of child Gridview  i need to display the combox for the first column. 
I  am trying to bind the data at runtime using C# in winForms. So please any help me on this to display combo box in the Hierarchy gridview.

Regards,
Sakthi

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 28 Jul 2010, 03:29 PM
Hi Sakthi,

Thank you for writing.

In regards to your question concerning adding a RadComboBox into the first column and last row of a child template, please consider the following code snippet:
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{   //ensure we are in a child
    if (e.CellElement.RowInfo.Parent != null)
    {   //ensure that we are modifing children only for row with ID (which is a column in the row) = 1 
        if (int.Parse(((GridViewDataRowInfo)e.CellElement.RowInfo.Parent).Cells["ID"].Value.ToString()) == 1)
        {   //find a certain column in the child by uniqueName
            if (e.CellElement.ColumnInfo.UniqueName == "ID")
            {
                GridViewInfo gridInfo = e.CellElement.RowInfo.ViewInfo;
                int rowsCount = gridInfo.Rows.Count;
                //If we are on the last row
                if (e.CellElement.RowIndex == rowsCount - 1)
                {   
                    if (e.CellElement.Children.Count == 0)
                    {
                        RadComboBoxElement combo = new RadComboBoxElement();
                        e.CellElement.Children.Add(combo);
                    }
                }
            }
        }
    }
}

More detailed information about RadGridView and its binding can be found in our help section.

I hope you find this information helpful.
 
Sincerely yours,
Stefan
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
Tags
GridView
Asked by
Sakthi
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or