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

Change Name GroupHeader with another Column

1 Answer 14 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
negar
Top achievements
Rank 1
negar asked on 07 Aug 2019, 06:09 AM

Hello, have good time
I have a page where it's a grid.

In this grid one of the columns is hidden where the user ID is and in the other column it fills the user name with another List in the event ItemDataBound
But when grouping it shows the user ID while I need the name to show it.

Aspx

01.<telerik:RadGrid ID="RadGrid1" runat="server" ShowFooter="true" AllowFilteringByColumn="true" GroupingEnabled="true" ShowGroupPanel="True"
02.                ClientSettings-AllowDragToGroup="true" AllowSorting="true" AllowPaging="true" PageSize="5" Skin="WebBlue" AllowMultiRowSelection="false" CellSpacing="-1" GridLines="Both"
03.                OnSelectedIndexChanged="RadGrid1_SelectedIndexChanged" OnPageIndexChanged="RadGrid1_PageIndexChanged" OnItemDataBound="RadGrid1_ItemDataBound">
04.                <ClientSettings EnablePostBackOnRowClick="true">
05.                    <Selecting AllowRowSelect="True" />
06.                    <ClientEvents OnRowCreated="onRowCreated" OnRowSelected="onRowSelected" OnRowDeselected="onRowDeselected"
07.                        OnGridCreated="gridCreated" OnGridCreating="masterTableCreating" />
08.                </ClientSettings>
09.                <GroupingSettings ShowUnGroupButton="true" GroupContinuesFormatString="" />
10.                <MasterTableView ShowGroupFooter="true" AutoGenerateColumns="False" DataKeyNames="Food_User_ID" ClientDataKeyNames="Food_ID_"
11.                    NoMasterRecordsText="اطلاعاتی برای نمایش وجود ندارد">
12.                    <Columns>
13.                        <telerik:GridClientSelectColumn UniqueName="SelectColumn" Visible="true" />
14.                        <telerik:GridTemplateColumn HeaderText="ردیف" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="100px" Groupable="false">
15.                            <ItemTemplate><%# (Container.ItemIndex+1).ToString() %> </ItemTemplate>
16.                        </telerik:GridTemplateColumn>
17.                        <telerik:GridBoundColumn DataField="Food_ID_" Groupable="false" DataType="System.Int32" FilterControlAltText="Filter Food_ID_ column"
18.                            HeaderText="" ReadOnly="True" SortExpression="Food_ID_" UniqueName="Food_ID_" Visible="false" />
19.                        <telerik:GridBoundColumn DataField="Food_Name" Groupable="true" FilterControlAltText="Filter Food_Name column"
20.                            HeaderText="نام" SortExpression="Food_Name" UniqueName="Food_Name" />
21.                        <telerik:GridBoundColumn DataField="Food_Price" Groupable="true" FilterControlAltText="Filter Food_Price column"
22.                            HeaderText="قیمت" SortExpression="Food_Price" UniqueName="Food_Price" DataType="System.Int32" />
23.                        <telerik:GridBoundColumn DataField="Food_Image" Groupable="false" FilterControlAltText="Filter Food_Image column"
24.                            HeaderText="تصویر" SortExpression="Food_Image" UniqueName="Food_Image" />
25.                        <telerik:GridBoundColumn DataField="Food_User_ID" Groupable="false" SortExpression="Food_User_ID"
26.                            HeaderText="" UniqueName="User_ID" DataType="System.Int32" Visible="false" />
27.                        <telerik:GridBoundColumn DataField="Food_User_ID" Groupable="true" FilterControlAltText="Filter Food_User_ID column"
28.                            HeaderText="کاربر" SortExpression="Food_User_ID" UniqueName="UserFLName" DataType="System.Int32" />
29.                        <telerik:GridCheckBoxColumn DataField="Food_Status" Groupable="false" DataType="System.Boolean" FilterControlAltText="Filter Food_Status column"
30.                            HeaderText="وضعیت" SortExpression="Food_Status" UniqueName="Food_Status" />
31.                    </Columns>
32.                </MasterTableView>
33.                <FilterMenu></FilterMenu>
34.                <HeaderContextMenu RenderMode="Classic"></HeaderContextMenu>
35.            </telerik:RadGrid>

 

C#

01.protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
02.        {
03.            if (e.Item is GridDataItem)// to access a row
04.            {
05.                GridDataItem item = (GridDataItem)e.Item;
06.                if (RadGrid1.GroupingEnabled)
07.                {
08.                    item["UserFLName"].Text = LstUser.FindAll(x => x.User_ID_ == int.Parse(item["User_ID"].Text))[0].User_FName + " " + LstUser.FindAll(x => x.User_ID_ == int.Parse(item["User_ID"].Text))[0].User_LName;
09.                }
10.            }
11.}

1 Answer, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 09 Aug 2019, 10:14 PM

Hi Negar,

This forum post is a duplicate of the https://www.telerik.com/forums/grouping-18d8005f844f. I have already answered it and I would suggest that we continue the discussion there.

This post will be closed to avoid the communication on multiple threads.

Kind regards, Attila Antal
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
negar
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Share this question
or