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

Grid Sorting Problem:- in the sorting date is only taking date and month part. It is not taking year part

2 Answers 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manish
Top achievements
Rank 2
Manish asked on 10 Jul 2012, 10:31 AM
Hi,

I have a grid and in that i have by default sorting by date desc and default group by by date and i is by default expended. The problem is that the sorting order is desc of date but the date is only taking the date and the month part in the not measuring by the sorting.
 
Please see the attachment.

I have used following code for sorting and grouping

 <SortExpressions >
                            <telerik:GridSortExpression FieldName="UpdatedDate" SortOrder="Descending"/>
                        </SortExpressions>
  <GroupByExpressions>
                            <telerik:GridGroupByExpression>
                                <GroupByFields>
                                    <telerik:GridGroupByField FieldName="UpdatedDate" SortOrder="Descending"  FormatString="{0:yy/mm/dd}" />
                                </GroupByFields>
                                <SelectFields>
                                    <telerik:GridGroupByField FieldName="UpdatedDate" />
                                </SelectFields>
                            </telerik:GridGroupByExpression>
                        </GroupByExpressions>
                        <GroupHeaderTemplate>
                            <asp:Label Text='<%#String.Format("{0:MM/dd/yy}", Eval("UpdatedDate"))%>' runat="server"
                                ID="lblDate" Style="font-weight: bold; color: Black;"></asp:Label>
                        </GroupHeaderTemplate>

2 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 12 Jul 2012, 02:07 PM
Hello Manish,

I have created a sample RadGrid web site using the provided code sample. On my side the sorting works as expected and takes into account the year too. Could you please ensure that your DataField's type is System.DateTime and not System.String? Please check out the attached application and try to distinguish the crucial differences between our projects.

Regards,
Eyup
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.
0
Manish
Top achievements
Rank 2
answered on 14 Jul 2012, 05:07 AM
Hi Eyup,

Thanks for your answer but i got the problem and it was that i was convert the date in database like Convert(string(10),updateddate,101)
so it was converting as string but i need to show it as i convert mm/dd/yyyy now i have made a solution i add another column and i make sorting with date and it was in date format  when i have to show the date in the groupby heading than shows converted date and in the shorting column i used the simple date column.


Thanks for your reply.


Thanks
Manish
Tags
Grid
Asked by
Manish
Top achievements
Rank 2
Answers by
Eyup
Telerik team
Manish
Top achievements
Rank 2
Share this question
or