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

Ommit column text for grouped rows

1 Answer 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Arnie Vargas
Top achievements
Rank 1
Arnie Vargas asked on 18 Sep 2012, 03:43 PM

I am trying to omit the text of a column when rows are grouped in my radgrid. The grouped column is "NAME".  So I want the data to display like this:

NAME                CITY     
CALIFORNIA      LOS ANGELES
                           SAN FRANCISCO
                           SAN DIEGO

TEXAS                HOUSTON
                            DALLAS

NEW YORK         NEW YORK
 

<telerik:RadGrid ID="gvArchives" runat="server" CellSpacing="0" DataSourceID="SGMFGPS" GridLines="None" Skin="Windows7" AutoGenerateColumns="False" ShowGroupPanel="True">

 <ClientSettings AllowDragToGroup="True"></ClientSettings>

 

 <MasterTableView DataKeyNames="RIEID" DataSourceID="SGMFGPS" GroupLoadMode="Client">

 <GroupHeaderTemplate>

 <asp:Label runat="server" ID="Label1" Text='<%# Eval("Name") %>'></asp:Label>

 </GroupHeaderTemplate>

 <Columns>

 <telerik:GridBoundColumn DataField="Name" FilterControlAltText="Filter Name column" HeaderText="Value Stream "  SortExpression="Name" UniqueName="Name" GroupByExpression="Name">

 </telerik:GridBoundColumn>

 <telerik:GridBoundColumn DataField="DepartmentName" FilterControlAltText="Filter DepartmentName column" HeaderText="Department Name" SortExpression="DepartmentName" UniqueName="DepartmentName">

 </telerik:GridBoundColumn>

 <telerik:GridBoundColumn DataField="RIEID" DataType="System.Int32" FilterControlAltText="Filter RIEID column" HeaderText="RIEID" ReadOnly="True" SortExpression="RIEID" UniqueName="RIEID" Visible="False">

 </telerik:GridBoundColumn>

 <telerik:GridBoundColumn DataField="RIEName" FilterControlAltText="Filter RIEName column" HeaderText="RIE Name" SortExpression="RIEName" UniqueName="RIEName">

 </telerik:GridBoundColumn>

 <telerik:GridBoundColumn DataField="Facilitator" FilterControlAltText="Filter Facilitator column" HeaderText="Facilitator" ReadOnly="True" SortExpression="Facilitator" UniqueName="Facilitator">

 </telerik:GridBoundColumn>

 <telerik:GridBoundColumn DataField="StartDate" DataType="System.DateTime" FilterControlAltText="Filter StartDate column" HeaderText="Start Date" SortExpression="StartDate" UniqueName="StartDate" DataFormatString="{0:d}"> </telerik:GridBoundColumn>

 <telerik:GridBoundColumn DataField="EndDate" DataType="System.DateTime" FilterControlAltText="Filter EndDate column" HeaderText="End Date" SortExpression="EndDate" UniqueName="EndDate" DataFormatString="{0:d}"> </telerik:GridBoundColumn>

 </Columns>
<GroupByExpressions>

 <telerik:GridGroupByExpression>

 <GroupByFields>

 <telerik:GridGroupByField FieldAlias="Name" FieldName="Name" FormatString="" HeaderText="Name" />

 </GroupByFields>

 </telerik:GridGroupByExpression>

 </GroupByExpressions>

 

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 21 Sep 2012, 10:04 AM
Hello Arnie,

Provided that each of your grid columns has identical DataField and UniqueName and you group only by fields that have corresponding columns, you could use the following code:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    if (RadGrid1.MasterTableView.GroupByExpressions.Count > 0)
    {
        foreach (GridGroupByExpression expr in RadGrid1.MasterTableView.GroupByExpressions)
        {
            string fieldName = expr.GroupByFields[0].FieldName;
            foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
            {
                item[fieldName].Text = "";
            }
        }
    }
}


All the best,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Arnie Vargas
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or