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

Group on GridTemplateColumn - Can not format Group Text

1 Answer 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kent Williams
Top achievements
Rank 1
Kent Williams asked on 03 Feb 2009, 07:05 PM
I have a GridTemplateColumn that I (finally) got the grouping to work how I want it to. However -- since this data is really a DateTime, it's showing up as "Loan Period: 01/01/2009 12:00:00 AM" instead of "Loan Period: 01/01/2009". How can I format ({0:d}) the group text?

            <telerik:GridTemplateColumn HeaderText="Loan Period" Groupable="true" DataField="BwrLoanStart" 
                SortExpression="BwrLoanStart" UniqueName="LoanPeriod" AllowFiltering="false" GroupByExpression="BwrLoanStart Group By BwrLoanStart">  
                <ItemTemplate> 
                <%# utils.removeEmptyDash(string.Format("{0:d} - {1:d}",Eval("BwrLoanStart"), Eval("BwrLoanEnd"))) %> 
                </ItemTemplate> 
                <ItemStyle CssClass="certcolpadding" /> 
            </telerik:GridTemplateColumn> 
All of the DateTime objects are gaurenteed to have the same time (12:00:00 AM). I kept everything as DateTIme objects instead of strings to ensure the correct sorting of the column.

Thanks!

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Feb 2009, 12:30 PM
Hi Kent,

Try accessing the GridGroupHeaderItem in the ItemDataBound event and format the text accordingly. Refer the following help article which explains how to access and customize the GridGroupHeaderItem.
Customizing GridGroupHeaderItem

Thanks
Shinu



Tags
Grid
Asked by
Kent Williams
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or