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

[Solved] Hierarchy with Templates Grid

4 Answers 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Suresh K
Top achievements
Rank 1
Suresh K asked on 28 Oct 2009, 07:37 AM
hi

I have a

Hierarchy with Templates Grid.Like This.



here i want to Expand the (RadGrid2).
And how to bind data to Inside Radgrid2 Controls.
In Which Event  i can bind data to Inside RadGrid2 Controls.
Can Anyone help me please....
   <telerik:RadGrid ShowGroupPanel="True" ID="RadGrid1"  AllowSorting="True" AutoGenerateColumns="False" 
            FilterItemStyle-BackColor="#ccff33" runat="server" GridLines="None" AllowPaging="True" 
            Width="750px" Skin="Hay" CellPadding="0"
            <ClientSettings> 
                <Selecting AllowRowSelect="True" /> 
            </ClientSettings> 
            <MasterTableView DataKeyNames="companyname"
                <NestedViewTemplate> 
                    <asp:Panel ID="Panel1" runat="server" BackImageUrl="~/images/bluegradient.gif"
                        <telerik:RadTabStrip runat="server" ID="TabStip1" Skin="Hay" MultiPageID="Multipage1" 
                            SelectedIndex="0" Width="464px"
                            <Tabs> 
                                <telerik:RadTab runat="server" Text="Unpaid Invoices" PageViewID="PageView2"
                                </telerik:RadTab> 
                                <telerik:RadTab runat="server" Text="Fully Paid Invoices" PageViewID="PageView3" 
                                    Selected="True"
                                </telerik:RadTab> 
                                <telerik:RadTab runat="server" Text="Part-Payments" PageViewID="PageView4"
                                </telerik:RadTab> 
                            </Tabs> 
                        </telerik:RadTabStrip> 
                        <telerik:RadMultiPage runat="server" ID="radmultipage1" SelectedIndex="0"
                            <telerik:RadPageView runat="server" ID="RadPageView1" style="margin-bottom:10px;margin-left :10px;margin-right :10px;margin-top :5px;"
                                <%--    <telerik:RadGrid ID="OrdersGrid" runat="server" Skin="Hay" Width="800px" AutoGenerateColumns="False" GridLines="None" OnPreRender="OrdersGrid_PreRender"
                                <ClientSettings > 
                                <Selecting AllowRowSelect ="True" /> 
                                <ClientEvents  /> 
                                </ClientSettings> 
                                <MasterTableView DataKeyNames ="loan_reference_number" > 
                                <NestedViewTemplate > 
                                <asp:Panel ID ="Panel2" runat ="server" > 
                                <telerik:RadTabStrip runat ="server" ID ="tabstrib1" MultiPageID ="Multipage2" SelectedIndex ="0" Width ="464px" Skin="Hay"
                                <Tabs > 
                                <telerik:RadTab runat ="server" Text ="Details" PageViewID ="newpageview2" Selected="True"></telerik:RadTab> 
                                <telerik:RadTab runat ="server" Text="Attachments" PageViewID ="newpageview3"></telerik:RadTab> 
                                <telerik:RadTab runat ="server" Text ="Comments" PageViewID ="newpageview3"></telerik:RadTab> 
                                </Tabs> 
                                </telerik:RadTabStrip> 
                                </asp:Panel> 
                                </NestedViewTemplate> 
                                    <Columns> 
                                        <telerik:GridBoundColumn DataField="loan_reference_number" HeaderText="Loan Reference NUmber" 
                                            UniqueName="column3"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="invoice_number" HeaderText="Invoice Number" UniqueName="column4"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField=" PSF_sanctionamount" HeaderText="PSF Sanction Amount" 
                                            UniqueName="column6"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="date_of_credit" HeaderText="Due Date" UniqueName="column1"
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="actual_debit_date" HeaderText="Grace Period" 
                                            UniqueName="column"
                                        </telerik:GridBoundColumn> 
                                    </Columns> 
                                    <ExpandCollapseColumn Visible="True"
                                    </ExpandCollapseColumn> 
                                </MasterTableView> 
                             
                            </telerik:RadGrid>--%> 
                                <telerik:RadGrid ID="RadGrid2" runat="server" AutoGenerateColumns="False" GridLines="None" 
                                    OnPreRender="RadGrid2_PreRender" Skin="Hay" OnNeedDataSource="RadGrid2_NeedDataSource"
                                    <ClientSettings> 
                                        <Selecting AllowRowSelect="True" /> 
                                    </ClientSettings> 
                                    <MasterTableView DataKeyNames="loan_reference_number" HierarchyLoadMode ="ServerOnDemand" > 
                                        <NestedViewTemplate> 
                                            <asp:Panel ID="detailsview" runat="server"
                                                <telerik:RadTabStrip runat="server" ID="newtip" Skin="Hay" MultiPageID="newradmultipage1" 
                                                    SelectedIndex="0" Width="312px"
                                                    <Tabs> 
                                                        <telerik:RadTab runat="server" Text="Details" PageViewID="PageView2" Selected="True"
                                                        </telerik:RadTab> 
                                                        <telerik:RadTab runat="server" Text="Comments" PageViewID="newPageView3"
                                                        </telerik:RadTab> 
                                                        <telerik:RadTab runat="server" Text="Attachments" PageViewID="newPageView4"
                                                        </telerik:RadTab> 
                                                    </Tabs> 
                                                </telerik:RadTabStrip> 
                                                <telerik:RadMultiPage runat="server" ID="newradmultipage1" SelectedIndex="0"
                                                    <telerik:RadPageView runat="server" ID="newRadPageView1"
                                                        <table style="width: 432px"
                                                            <tr> 
                                                                <td style="width: 74px"
                                                                </td> 
                                                                <td style="width: 100px"
                                                                </td> 
                                                                <td style="width: 100px"
                                                                </td> 
                                                            </tr> 
                                                            <tr> 
                                                                <td style="width: 74px"
                                                                    <asp:Label ID="Label2" runat="server" Text="Reference Number:" Width="144px" Style="text-align: left"></asp:Label></td
                                                                <td style="width: 100px"
                                                                    <asp:Label ID="lblreferencename" runat="server" Text="Referencenumber" Width="150px"></asp:Label> 
                                                                </td> 
                                                                <td style="width: 100px"
                                                                </td> 
                                                            </tr> 
                                                            <tr> 
                                                                <td style="width: 74px"
                                                                    <asp:Label ID="Label3" runat="server" Text="Invoice Number:" Width="144px" Style="text-align: left"></asp:Label> 
                                                                </td> 
                                                                <td style="width: 100px"
                                                                    <asp:Label ID="lblinvoicenumber" runat="server" Text="Invoicenumber" Width="150px"></asp:Label></td
                                                                <td style="width: 100px"
                                                                </td> 
                                                            </tr> 
                                                            <tr> 
                                                                <td style="width: 74px"
                                                                    <asp:Label ID="Label4" runat="server" Text="Company Name:" Width="144px" Style="text-align: left"></asp:Label></td
                                                                <td style="width: 100px"
                                                                    <asp:Label ID="lblcompanyname" runat="server" Text="Companyname" Width="150px"></asp:Label></td
                                                                <td style="width: 100px"
                                                                </td> 
                                                            </tr> 
                                                            <tr> 
                                                                <td style="width: 74px"
                                                                    <asp:Label ID="Label6" runat="server" Text="Due Date:" Width="144px" Style="text-align: left"></asp:Label></td
                                                                <td style="width: 100px"
                                                                    <asp:Label ID="lblduedate" runat="server" Text="Duedate" Width="150px"></asp:Label></td
                                                                <td style="width: 100px"
                                                                </td> 
                                                            </tr> 
                                                            <tr> 
                                                                <td style="width: 74px"
                                                                    <asp:Label ID="Label7" runat="server" Text="Grace Day:" Width="144px" Style="text-align: left"></asp:Label></td
                                                                <td style="width: 100px"
                                                                    <asp:Label ID="lblgraceday" runat="server" Text="Graceday" Width="150px"></asp:Label></td
                                                                <td style="width: 100px"
                                                                </td> 
                                                            </tr> 
                                                            <tr> 
                                                                <td style="width: 74px"
                                                                    <asp:Label ID="Label8" runat="server" Text="Maturity Date:" Width="144px" Style="text-align: left"></asp:Label></td
                                                                <td style="width: 100px"
                                                                    <asp:Label ID="lblmaturitydate" runat="server" Text="Maturitydate" Width="150px"></asp:Label></td
                                                                <td style="width: 100px"
                                                                </td> 
                                                            </tr> 
                                                            <tr> 
                                                                <td style="width: 74px"
                                                                    <asp:Label ID="Label5" runat="server" Text="Client Name:" Visible="false" Width="144px" 
                                                                        Style="text-align: left"></asp:Label></td
                                                                <td style="width: 100px"
                                                                    <asp:Label ID="lblclientname" runat="server" Text="Clientname" Width="150px" Visible="False"></asp:Label></td
                                                                <td style="width: 100px"
                                                                </td> 
                                                            </tr> 
                                                        </table> 
                                                    </telerik:RadPageView> 
                                                    &nbsp;&nbsp; 
                                                    <telerik:RadPageView ID="RadPageView2" runat="server"
                                                        <telerik:RadEditor ID="RadEditComment" runat="server" Skin="Hay" Style="position: static; 
                                                            margin-left: 10px;" Enabled="false" Width="98%" EditModes="Design"
                                                            <Tools> 
                                                                <telerik:EditorToolGroup> 
                                                                </telerik:EditorToolGroup> 
                                                            </Tools> 
                                                            <Content> 
                                                            </Content> 
                                                        </telerik:RadEditor> 
                                                    </telerik:RadPageView> 
                                                    <asp:Button ID="Button2" runat="server" Text="Button" /> 
                                                    <telerik:RadPageView ID="RadPageView3" runat="server"
                                                        <asp:Panel ID="Panelatchmt" runat="server" BorderColor="ActiveBorder" BorderWidth="1px" 
                                                            Style="position: static" Visible="true" Width="690px"
                                                            <table style="position: static"
                                                                <tr> 
                                                                    <td colspan="3" valign="middle"
                                                                        <table style="width: 100%; position: static"
                                                                            <tr> 
                                                                                <td style="width: 100px"
                                                                                    <asp:Label ID="Label1grd" runat="server" Style="position: static" Text="Document Name" 
                                                                                        Font-Names="Arial Narrow" ForeColor="#7D7D7D" Width="103px"></asp:Label></td
                                                                                <td style="width: 100px"
                                                                                    <asp:TextBox ID="txttitlegrd" runat="server" Style="position: static" Width="144px"></asp:TextBox></td
                                                                                <td colspan="2"
                                                                                    <asp:FileUpload ID="FileUpload1grd" runat="server" BorderColor="#4EB106" Style="position: static" 
                                                                                        TabIndex="7" Width="264px" BorderWidth="1px" /></td
                                                                                <td style="width: 100px"
                                                                                    <telerik:RadComboBox ID="cmbtypegrd" runat="server" Style="position: static" Width="75px" 
                                                                                        Skin="Hay"
                                                                                        <Items> 
                                                                                            <telerik:RadComboBoxItem runat="server" Text="Front" Value="Front" /> 
                                                                                            <telerik:RadComboBoxItem runat="server" Text="Back" Value="Back" /> 
                                                                                        </Items> 
                                                                                    </telerik:RadComboBox> 
                                                                                </td> 
                                                                                <td style="width: 100px"
                                                                                    <asp:Button ID="btnSavegrd" runat="server" Style="position: static" TabIndex="8" 
                                                                                        Text="Attach" ValidationGroup="valdg3grd" Width="70px" OnClick="btnSavegrd_Click" /></td
                                                                            </tr> 
                                                                        </table> 
                                                                    </td> 
                                                                </tr> 
                                                                <tr> 
                                                                    <td colspan="3"
                                                                        <telerik:RadGrid ID="RadGrdAttach" runat="server" ShowGroupPanel="True" AutoGenerateColumns="False" 
                                                                            Skin="Hay" Width="690px" GridLines="None"
                                                                            <MasterTableView> 
                                                                                <Columns> 
                                                                                    <telerik:GridTemplateColumn UniqueName="TemplateColumn"
                                                                                        <HeaderTemplate> 
                                                                                            Download</HeaderTemplate> 
                                                                                        <ItemTemplate> 
                                                                                            <asp:LinkButton ID="btndown" runat="server" CommandName="Select" Text="Download"></asp:LinkButton> 
                                                                                        </ItemTemplate> 
                                                                                    </telerik:GridTemplateColumn> 
                                                                                    <telerik:GridBoundColumn DataField="serialnumber" HeaderText="id" ReadOnly="True" UniqueName="id" 
                                                                                        Visible="False"
                                                                                    </telerik:GridBoundColumn> 
                                                                                    <telerik:GridBoundColumn DataField="filename" HeaderText="FileName" UniqueName="FileName"
                                                                                    </telerik:GridBoundColumn> 
                                                                                    <telerik:GridBoundColumn DataField="tname" HeaderText="DocumentName" UniqueName="DocumentName"
                                                                                    </telerik:GridBoundColumn> 
                                                                                    <telerik:GridBoundColumn DataField="uploadedby" HeaderText="Uploaded By" UniqueName="uploadedby"
                                                                                    </telerik:GridBoundColumn> 
                                                                                </Columns> 
                                                                                <GroupByExpressions> 
                                                                                    <telerik:GridGroupByExpression> 
                                                                                        <SelectFields> 
                                                                                            <telerik:GridGroupByField FieldAlias="Attachments" FieldName="groupname" FormatString="{0:D}" 
                                                                                                HeaderValueSeparator=" from: " /> 
                                                                                        </SelectFields> 
                                                                                        <GroupByFields> 
                                                                                            <telerik:GridGroupByField FieldAlias="groupname" FieldName="groupname" SortOrder="Descending" /> 
                                                                                        </GroupByFields> 
                                                                                    </telerik:GridGroupByExpression> 
                                                                                </GroupByExpressions> 
                                                                            </MasterTableView> 
                                                                        </telerik:RadGrid> 
                                                                    </td> 
                                                                </tr> 
                                                                <tr> 
                                                                    <td colspan="3" style="width: 100px;"
                                                                        <table style="position: static"
                                                                            <tr> 
                                                                                <td style="width: 100px"
                                                                                    <asp:Button ID="btnfrontgrd" runat="server" Style="position: static" Enabled="false" 
                                                                                        Text="View Front" /></td
                                                                                <td style="width: 100px"
                                                                                    <asp:Button ID="btnbackgrd" runat="server" Style="position: static" Enabled="false" 
                                                                                        Text="View Back" /></td
                                                                                <td style="width: 100px"
                                                                                </td> 
                                                                                <td style="width: 100px"
                                                                                </td> 
                                                                                <td style="width: 100px"
                                                                                </td> 
                                                                                <td style="width: 100px"
                                                                                </td> 
                                                                                <td style="width: 100px"
                                                                                </td> 
                                                                                <td style="width: 100px"
                                                                                    <asp:Button ID="btndownloadgrd" runat="server" Style="position: static" Enabled="false" 
                                                                                        Text="Download" /></td
                                                                                <td style="width: 100px"
                                                                                    <asp:Button ID="btnprintgrd" runat="server" Style="position: static" Text="Print" 
                                                                                        Visible="False" /></td
                                                                            </tr> 
                                                                        </table> 
                                                                    </td> 
                                                                </tr> 
                                                            </table> 
                                                            <br /> 
                                                            <iframe style="position: static;" id="fimageview" width="690" runat="server"></iframe> 
                                                            &nbsp;</asp:Panel> 
                                                    </telerik:RadPageView> 
                                                </telerik:RadMultiPage> 
                                            </asp:Panel> 
                                        </NestedViewTemplate> 
                                        <Columns> 
                                            <telerik:GridBoundColumn DataField="loan_reference_number" HeaderText="Loan Reference Number" 
                                                UniqueName="column1"
                                            </telerik:GridBoundColumn> 
                                            <telerik:GridBoundColumn DataField="invoice_number" HeaderText="Invoice Number" UniqueName="column2"
                                            </telerik:GridBoundColumn> 
                                            <telerik:GridBoundColumn DataField="date_of_credit" HeaderText="Due Date" UniqueName="column3"
                                            </telerik:GridBoundColumn> 
                                            <telerik:GridBoundColumn DataField="actual_debit_date" HeaderText="Grace Period" 
                                                UniqueName="column"
                                            </telerik:GridBoundColumn> 
                                        </Columns> 
                                        <ExpandCollapseColumn Visible="True"
                                        </ExpandCollapseColumn> 
                                    </MasterTableView> 
                                </telerik:RadGrid></telerik:RadPageView> 
                        </telerik:RadMultiPage> 
                        <br /> 
                    </asp:Panel> 
                </NestedViewTemplate> 
                <Columns> 
                    <telerik:GridBoundColumn DataField="companyname" HeaderText="Company name" UniqueName="column1" 
                        Visible="False"
                        <ItemStyle Height="15px" /> 
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="currency" HeaderText="Currency" UniqueName="column3" 
                        Visible="False"
                        <ItemStyle Height="15px" /> 
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="overdraftlimit" HeaderText="Over Draft Limit" 
                        UniqueName="column" DataFormatString="&lt;pre&gt;{0}"
                        <HeaderStyle HorizontalAlign="Center" /> 
                        <ItemStyle Height="15px" /> 
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="Credit Utilized" HeaderText="Credit Utilized" 
                        UniqueName="column10" DataFormatString="&lt;pre&gt;{0}"
                        <HeaderStyle HorizontalAlign="Center" /> 
                        <ItemStyle Height="15px" /> 
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="Available Credit" HeaderText="Available Credit" 
                        UniqueName="column8" DataFormatString="&lt;pre&gt;{0}" FooterText="Selected Company Total:"
                        <HeaderStyle HorizontalAlign="Center" /> 
                        <ItemStyle Height="15px" /> 
                    </telerik:GridBoundColumn> 
                </Columns> 
                <GroupByExpressions> 
                    <telerik:GridGroupByExpression> 
                        <GroupByFields> 
                            <telerik:GridGroupByField FieldName="companyname" FieldAlias="companyname" /> 
                        </GroupByFields> 
                        <SelectFields> 
                            <telerik:GridGroupByField FieldName="companyname" FieldAlias="companyname" /> 
                        </SelectFields> 
                    </telerik:GridGroupByExpression> 
                </GroupByExpressions> 
                <ExpandCollapseColumn Visible="True"
                </ExpandCollapseColumn> 
            </MasterTableView> 
            <FilterItemStyle BackColor="#CCFF33" /> 
            <SelectedItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /> 
        </telerik:RadGrid> 

Thank You.
Suresh K.


4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 Oct 2009, 10:05 AM
Hi,

Try the code snippet below to access the controls  in the NestedViewTemplate. You need to fire the PreRender event of the RadGrid2  and access the controls  (eg RadGrdAttach) in it.

C#
 protected void RadGrid2_PreRender(object sender, EventArgs e) 
    { 
        RadGrid RadGrid2 = sender as RadGrid; 
        foreach (GridDataItem dataItem in RadGrid2.Items) 
        { 
            if (dataItem.Expanded) 
            { 
                GridNestedViewItem nestedItem = (GridNestedViewItem)dataItem.ChildItem; 
                RadGrid RadGrdAttach = (RadGrid)nestedItem.FindControl("RadGrdAttach"); 
                RadGrdAttach.DataSource = dtTable; 
                RadGrdAttach.DataBind(); 
            } 
        } 
    } 


Thanks,
Princy
0
Suresh K
Top achievements
Rank 1
answered on 30 Oct 2009, 06:38 AM
hi.
Thanks for your Response.
I Tryed This code.
i am able to finding Controls in side RadGrid2.
But.it do not Expanding the Grid.

If dataItem.Expanded Then
end if

dataItem.Expanded condition showing False.It's not Entering into if statement





Any Other Way.Could you please help me.

Thank you.
Suresh K.

0
Princy
Top achievements
Rank 2
answered on 30 Oct 2009, 08:05 AM
Hello Suresh,

The dataItem.Expanded condition will fire only on expanding RadGrid2. If you want to access the controls without expanding the grid, then you can set the HierarchyLoadMode property for the RadGrid2<MasterTableView to Client.
aspx:
<telerik:RadGrid ID="RadGrid2" runat="server" AutoGenerateColumns="False" GridLines="None" OnPreRender="RadGrid2_PreRender" Skin="Hay" OnNeedDataSource="RadGrid2_NeedDataSource">  
      <ClientSettings>  
           .... 
       </ClientSettings>  
       <MasterTableView DataKeyNames="loan_reference_number" HierarchyLoadMode ="Client">  
          <NestedViewTemplate>  
              <asp:Panel ID="detailsview" runat="server">   
                 ....                                            

c#:
protected void RadGrid2_PreRender(object sender, EventArgs e)  
    {  
        RadGrid RadGrid2 = sender as RadGrid;  
        foreach (GridDataItem dataItem in RadGrid2.Items)  
        {             
                GridNestedViewItem nestedItem = (GridNestedViewItem)dataItem.ChildItem;  
                RadGrid RadGrdAttach = (RadGrid)nestedItem.FindControl("RadGrdAttach");  
                RadGrdAttach.DataSource = dtTable;  
                RadGrdAttach.DataBind();               
        }  
    }  

Thanks
Princy.
0
Suresh K
Top achievements
Rank 1
answered on 31 Oct 2009, 05:06 AM
Hi.
Thanks again to your response.
It Happened When i try to expand The  Radgrid2.
if i do  HierarchyLoadMode ="Client".
It doesn't going to server side to find the Controls and Bind Data.

If i do HierarchyLoadMode ="ServerOnDemand", HierarchyLoadMode="ServerBind"






 also not working .,

Any Other Way Please......

Thank you .
Suresh k.,
Tags
Grid
Asked by
Suresh K
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Suresh K
Top achievements
Rank 1
Share this question
or