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

Group header - change boolean to something more meaningful

1 Answer 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jerzy
Top achievements
Rank 1
Jerzy asked on 28 Sep 2012, 06:34 PM
I have RadGrid with grouping enabled on boolean field. The thing is, group header contains field value True or False, which I'd like to change to something like Yes or No.

I know I could alternate the text on ItemDataBound event, but that is not very flexible - it will always change True/False to Yes/No, even when there will be actual need to display True/False.

Are there any aleternative approaches for changing group header text?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Oct 2012, 10:38 AM
Hi,


Please check the following code snippet I tried to change the GroupHeaderText from True/False to Yes/No.
ASPX:
<GroupByExpressions>
        <telerik:GridGroupByExpression>
            <SelectFields>
                <telerik:GridGroupByField FieldName="IsValid" />
            </SelectFields>
            <GroupByFields>
                <telerik:GridGroupByField FieldName="FirstName"  />
            </GroupByFields>
        </telerik:GridGroupByExpression>
</GroupByExpressions>
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridGroupHeaderItem)
    {
        GridGroupHeaderItem hitem = (GridGroupHeaderItem)e.Item;
 
        DataRowView groupDataRow = (DataRowView)e.Item.DataItem;
        if (groupDataRow["FirstName"].ToString() == "Robin")
        {
            if (groupDataRow["IsValid"].ToString() == "False")
            {
                hitem.DataCell.Text = "IsValid:No";
            }
            else
            {
                hitem.DataCell.Text = "IsValid:Yes";
            }
        }
    }
}
Thanks,
Princy.
Tags
Grid
Asked by
Jerzy
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or