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

Expand specific GridTableView item on Page Load

2 Answers 242 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mário
Top achievements
Rank 1
Mário asked on 18 Jun 2014, 05:46 PM
Hello,

I have the following code:

<telerik:RadGrid ID="rgProcessos" runat="server" ShowStatusBar="true" ShowFooter="false" CssClass="RadGrid"
                        AutoGenerateColumns="false" AllowSorting="true" AllowMultiRowSelection="false"
                        AllowPaging="true" OnDetailTableDataBind="rgProcessos_DetailTableDataBind"
                        OnNeedDataSource="rgProcessos_NeedDataSource" OnItemCommand="rgProcessos_ItemCommand"
                        OnItemCreated="rgProcessos_ItemCreated" OnColumnCreated="rgProcessos_ColumnCreated"
                        AllowFilteringByColumn="true"
                        PageSize="100">
                        <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" Position="Bottom" PagerTextFormat="páginas: {4} | página {0} de {1}, registo {2} a {3} de {5}" />
                        <MasterTableView DataKeyNames="PRC_Cod, Alerta" Name="Processos">
 
                            <DetailTables>
                                <telerik:GridTableView DataKeyNames="ADI_Cod" Name="Aditamentos" Width="100%" ShowFooter="false" AllowFilteringByColumn="false" AllowPaging="false">
                                    <DetailTables>
                                        <telerik:GridTableView Name="Documentos" Width="100%" AllowFilteringByColumn="false" AllowPaging="false">
                                            <Columns>
                                                <telerik:GridBoundColumn HeaderText="Nr Ordem" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" DataField="DDD_Num_Ordem" />
                                                <telerik:GridBoundColumn HeaderText="Nr Documento" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" DataField="DDD_Num_Doc" />
                                                <telerik:GridBoundColumn HeaderText="Data" DataFormatString="{0:dd/MM/yyyy}" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" DataField="DDD_Data" />
                                                <telerik:GridBoundColumn HeaderText="Estado" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" DataField="EST_Designacao" />

I want to do what the title says :) So, on page load (automatically) i want to expand one or more items of the GridTableView's. Appreciate any help.
Thanks,
Mário

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 19 Jun 2014, 05:21 AM
Hi Mario,

Please take a look into the following code snippet to expand the first row of the parent and DetailTable on page load.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
     if (!Page.IsPostBack)
     {
            RadGrid1.MasterTableView.Items[0].Expanded = true; //Expanding the first row of Mastertable
            RadGrid1.MasterTableView.Items[0].ChildItem.NestedTableViews[0].Items[0].Expanded = true;// Expanding the first child row
     }
}

Thanks,
Princy.
0
Mário
Top achievements
Rank 1
answered on 19 Jun 2014, 01:23 PM
Thanks Prince.
That help me reach the solution i was looking for.
Tags
Grid
Asked by
Mário
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mário
Top achievements
Rank 1
Share this question
or