Sortting with Date type in telerik:GridTemplateColumn

8 posts, 0 answers
  1. nguyen
    nguyen avatar
    19 posts
    Member since:
    Aug 2012

    Posted 26 Aug 2011 Link to this post

    Hello,

     I've Sortting  with Date type but use telerik:GridTemplateColumn in radGrid. But it always sort like string type, note date type. My code is:

        <telerik:GridTemplateColumn HeaderText="Date" ItemStyle-Width="100"
                                SortExpression="Date" UniqueName="Date" DataField="Date"
                                CurrentFilterFunction="Contains" ShowFilterIcon="false" AutoPostBackOnFilter="true"
                                FilterControlWidth="100%">
                                <HeaderStyle Font-Bold="true" />
                                <ItemStyle Width="70" />
                                <ItemTemplate>
                                    <%# (ConvertHelper.ToDateTime(Eval("Date"))).ToString("dd.MM.yyyy")%>
                                </ItemTemplate>
                                 <EditItemTemplate>
                                    <telerik:RadDatePicker ID="rdDate" runat="server" Culture="German (Switzerland)" Width="100"
                                        Skin="abc" EnableEmbeddedSkins="false" SelectedDate='<%# (ConvertHelper.ToDateTime(Eval("Date"))) %>'>
                                        <DateInput Width="70" runat="server">
                                        </DateInput>
                                    </telerik:RadDatePicker>
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>

    Please help me sortting in this case. Use <telerik:GridTemplateColumn>.....</telerik:GridTemplateColumn and Sortting by Date Type, not string type.

    Thanks, 

    Nguyen Quang Hung
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 26 Aug 2011 Link to this post

    Hello,

    <telerik:GridTemplateColumn DataType="System.DateTime">


    Thanks,
    Jayesh Goyani
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. nguyen
    nguyen avatar
    19 posts
    Member since:
    Aug 2012

    Posted 26 Aug 2011 Link to this post


    Thank Jayesh Goyani!

    But when  I  add property DataType="System.DateTime". It still error!
    maybe because with format ToString("dd.MM.yyyy") in: 
                        ...........
                               <ItemTemplate>
                                   <%# (ConvertHelper.ToDateTime(Eval("Date"))).ToString("dd.MM.yyyy")%>
                                </ItemTemplate>
                        ..........
    and rad control sortting by string type. I don't know how to fix it.

     
  5. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 26 Aug 2011 Link to this post

    Hello,

    Eval("Date")

    This Date is in Date format or String format ?

    Thanks,
    Jayesh Goyani
  6. nguyen
    nguyen avatar
    19 posts
    Member since:
    Aug 2012

    Posted 26 Aug 2011 Link to this post

    thank Jayesh Goyan a lot, 

    my problem is fixed.
  7. nguyen
    nguyen avatar
    19 posts
    Member since:
    Aug 2012

    Posted 31 Aug 2011 Link to this post

    Hello,
     I've another problem:  when i add <telerik:GridTemplateColumn DataType="System.DateTime">. Sortting is ok but but the filter function error. 
    i think Filterring by data type "string"
     



      
  8. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 31 Aug 2011 Link to this post

    Hello,

    please check below link for handle this thing manually.
    http://www.telerik.com/help/aspnet/grid/grdfilteringfordatetimecolumnwithdataformatstring.html

    Thanks,
    Jayesh Goyani
  9. Jaya
    Jaya avatar
    81 posts
    Member since:
    Mar 2011

    Posted 17 Apr 2015 in reply to Jayesh Goyani Link to this post

    Hello

    Jayesh

     

    can you solve this url

     

    http://www.telerik.com/forums/how-to-changes-telerik-grid-running-total-footer-template

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017