Declined
Last Updated: 09 Aug 2016 13:51 by ADMIN
ADMIN
Nikolay
Created on: 09 Sep 2013 07:53
Category: GridView
Type: Feature Request
0
ADD. RadGridView - add convenient API for accessing child TableElement
There should be a convenient and more straightforward API for accessing the TableElement of a child gridview. Currently, the API is:
void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement is GridDetailViewCellElement)
    {
        ((GridDetailViewCellElement)e.CellElement).ChildTableElement.RowHeight = 50;
    }
}
1 comment
ADMIN
Ralitsa
Posted on: 09 Aug 2016 13:51
The GridTableElement objects associated with each child template are created on demand during the initialization of the GridDetailViewCellElement. This behavior is by design and it enhances the performance of the control.

The preferred way to access the GridTableElements is in a formatting event: ViewCellFormatting (http://docs.telerik.com/devtools/winforms/gridview/cells/formatting-cells#viewcellformatting---formatting-non-data-cells)

private void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    GridDetailViewCellElement detailCell = e.CellElement as GridDetailViewCellElement;
    if (detailCell != null)
    {
        detailCell.ChildTableElement.RowHeight = 50;
    }
}

It is also possible to access the table elements by iterating the logical rows. This approach will be only valid for rows which are expanded as only then they will have a GridTableElement . The example below demonstrates how one can store the horizontal scrollbar values of for all table elements of the rows which are expanded:

Queue<int> horizontalScrollbarQueue = new Queue<int>();
foreach (GridViewRowInfo row in this.grdData.Rows)
{
    GridViewHierarchyRowInfo hierarhyRow = row as GridViewHierarchyRowInfo;
    if (hierarhyRow != null && hierarhyRow.IsExpanded)
    {
        GridTableElement table = grdData.GridViewElement.GetRowView(hierarhyRow.ActiveView) as GridTableElement;
        if (table != null)
        {
            horizontalScrollbarQueue.Enqueue(table.HScrollBar.Value);
        }
    }
}