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

Access the grid column headings text in a NestedViewTemplate

3 Answers 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dominic
Top achievements
Rank 1
Dominic asked on 17 Sep 2014, 09:19 AM
I have a grid (rgEmployeeData) that has a NestedViewTemplate which contains a RadGrid (rgLogs)
Both grids are populated using a client side calls via AJAX to a webservice.

Question is ... at the point of loading the page for the first time I want to change the text of each column heading in the Nested grid.
The reason is to apply different heading text (that is stored in the database) depending on the users locale.

Could someone direct me as to how this can be achieved either Client side or in the Page_Load / Page_Init ?

<telerik:RadGrid ID="rgEmployeeData" runat="server" AutoGenerateColumns="False" AllowFilteringByColumn="false"
    AllowPaging="true" PageSize="50" ShowHeaderWhenEmpty="true" AllowSorting="true"
    AllowCustomPaging="true">
    <ClientSettings>
        <Scrolling AllowScroll="false" UseStaticHeaders="true" />
        <DataBinding ShowEmptyRowsOnLoad="false" />
        <ClientEvents OnCommand="rgEmployeeData_Command"
                      OnHierarchyExpanding="rgEmployeeData_HierarchyExpanding" />
        <Resizing AllowColumnResize="true" AllowRowResize="false" ResizeGridOnColumnResize="true"
            ClipCellContentOnResize="true" EnableRealTimeResize="false" AllowResizeToFit="true" />
    </ClientSettings>
    <MasterTableView TableLayout="Auto" AutoGenerateColumns="false" CommandItemDisplay="None"
        HierarchyDefaultExpanded="false" HierarchyLoadMode="Client" ClientDataKeyNames="RecordID">
        <PagerStyle AlwaysVisible="true" Mode="NumericPages"  />
        <Columns>
            <telerik:GridBoundColumn HeaderText="RecordID" Visible="false" UniqueName="RecordID"
                DataField="RecordID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn
                HeaderText="Address"
                HeaderStyle-Wrap="false"
                UniqueName="Address"
                DataField="Address">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn
                HeaderText="PostCode"
                HeaderStyle-Wrap="false"
                ItemStyle-Wrap="false"
                UniqueName="PostCode"
                DataField="PostCode"
                ItemStyle-Width="100"
                HeaderStyle-Width="100">
            </telerik:GridBoundColumn>
        </Columns>
        <NestedViewTemplate>
              <telerik:RadButton runat="server" Text="xEnquiry"
                    id="witnCreateSMS" OnClientClicking="addEnq"
                    ButtonType="StandardButton" AutoPostBack="false"
                    ToolTip="XAdd Enquiry">
                    <Icon PrimaryIconUrl="../../Images/GridButtons/plusicon.png" PrimaryIconLeft="4" PrimaryIconTop="4" />
              </telerik:RadButton>
 
              <telerik:RadButton runat="server" Text="xLog"
                    id="RadButton1" OnClientClicking="addLog"
                    ButtonType="StandardButton" AutoPostBack="false"
                    ToolTip="XAdd Log">
                    <Icon PrimaryIconUrl="../../Images/GridButtons/plusicon.png" PrimaryIconLeft="4" PrimaryIconTop="4" />
              </telerik:RadButton>
 
              <telerik:RadGrid ID="rgLogs" AllowFilteringByColumn="false" runat="server" PageSize="1"
                AllowPaging="false" AllowSorting="false" Width="90%" SkinID="RCSNestedGrid"   >
                <ClientSettings>
                    <ClientEvents OnCommand="rgLogs_Command" />
                    <DataBinding ShowEmptyRowsOnLoad="false" />
                    <Resizing AllowColumnResize="true" />
                </ClientSettings>
                <MasterTableView ClientDataKeyNames="LogID" >
                    <Columns>
                        <telerik:GridBoundColumn Visible="false" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"
                            DataField="RecordID" HeaderText="RecordID" DataType="System.Int32" />
                        <telerik:GridBoundColumn
                            HeaderStyle-Wrap="false"
                            ItemStyle-Wrap="false"
                            SortExpression="FollowUpDate"
                            HeaderStyle-Width="90"
                            DataField="FollowUpDate"
                            HeaderText="FollowUpDate"
                            DataType="System.String" />
                        <telerik:GridBoundColumn
                            ItemStyle-Wrap="false"
                            SortExpression="Type"
                            DataField="Type"
                            HeaderText="Type"
                            DataType="System.String"
                            HeaderStyle-Width="10%" />
                    </Columns>
                </MasterTableView>
                <PagerStyle AlwaysVisible="false" />
            </telerik:RadGrid>
        </NestedViewTemplate>
    </MasterTableView>
</telerik:RadGrid>

3 Answers, 1 is accepted

Sort by
0
Accepted
Pavlina
Telerik team
answered on 22 Sep 2014, 09:37 AM
Hello,

You can handle on nested grid PreRender event find the column you wish by its UniqueName and change its HeaderText. Then you should call grid Rebind() in order to reflect the changes. 

Regards,
Pavlina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Dominic
Top achievements
Rank 1
answered on 20 Oct 2014, 09:28 AM
Thank you for the reply, that seems fine.

Just one more question, how would I access the NestedView buttons "witnCreateSMS" and "RadButton1".
I want to have the option to disable/enable them according to various criteria in the code behind (C#).

many thanks
0
Accepted
Pavlina
Telerik team
answered on 23 Oct 2014, 09:23 AM
Hi Dominic,

You can try using the code snippet below to access the witnCreateSMS button and see if it works:
protected void Page_Load(object sender, EventArgs e)
    {
        foreach (GridDataItem item in rgEmployeeData.MasterTableView.Items)
        {
            if (!item.Expanded)
            {
                GridNestedViewItem nestedItem = (GridNestedViewItem)item.ChildItem;
                RadButton button= (RadButton)nestedItem.FindControl("witnCreateSMS");
            }
        }
          
    }

Regards,
Pavlina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Dominic
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Dominic
Top achievements
Rank 1
Share this question
or