Change sorting when filtering

4 posts, 0 answers
  1. Jon
    Jon avatar
    12 posts
    Member since:
    Jul 2010

    Posted 02 Aug 2010 Link to this post

    Group,
    I am sure there is an easy answer to this, but I am having trouble finding it.  I am using a RadGrid with filtering by columns.  One of the columns is a DateTime column.

    for the filter I am using the GreaterthanOrEqualTo filter.  What I want to have happen is have the Grid sort by date descending on page load so the most recent transaction is first, but when a date is typed into the filter I want it to sort Ascending so the closes transaction to that date appears at the top of the list.

    Is there a way to set a sort order when filtering?

    Also, in the filter when I select a date from the date picker it doesn't post back.  I have to hit enter for it to apply the filter because I hid the filter button and defaulted it to GreaterthanOrEqualTo.  In my situation it would be ideal to fire the filter when picking a date.  Is there a way to change that?  I am sure I could do it with javascript but not sure if there is something already built in.

    Any help is greatly appreciated.
  2. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 05 Aug 2010 Link to this post

    Hello Jon,

    Straight to your questions:
    1. To implement the desired functionality, I recommend that you set the desired sorting expression when the grid is filtered:
      protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
      {
       if (e.CommandName == RadGrid.FilterCommandName)
       {
         //...
       }
      }
    2. Please set the AutoPostBackOnFilter property of the corresponding column to true to trigger postback filter operation when Enter is pressed.

    I hope this helps.

    Regards,
    Mira
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jon
    Jon avatar
    12 posts
    Member since:
    Jul 2010

    Posted 05 Aug 2010 Link to this post

    Hi Mira,
    The answer to question 1 worked great thanks!

    Question 2. I have the autopostback set to true on that column.  The issue is when I select a date from the filter it selects a date and fills the filter textbox with that date, but doesn't postback. If I hit enter it stiil does nothing because focus has been lost.  If I click back into the filter textbox and hit enter it will trigger a postback.

    Basically if I select a date and hit enter it does nothing until I put focus back onto the filter textbox containing the date and hit enter.  Ideally the postback would occur when I select a date and not even have to hit enter. However, having to hit enter after selecting a date doesn't bother me if I can get around the issue of having to click back into the filter textbox.

    Thanks again for your help. You guys are great!
    Jon
  5. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 09 Aug 2010 Link to this post

    Hello Jon,

    I have followed your scenario and prepared a sample project for you implementing it. You can find it attached to this message.

    Please take a look at it and let me know whether it helps.

    Regards,
    Mira
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top