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

Change sorting when filtering

3 Answers 39 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 02 Aug 2010, 05:25 PM
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.

3 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 05 Aug 2010, 10:37 AM
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
0
Jon
Top achievements
Rank 1
answered on 05 Aug 2010, 03:06 PM
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
0
Mira
Telerik team
answered on 09 Aug 2010, 12:25 PM
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
Tags
Filter
Asked by
Jon
Top achievements
Rank 1
Answers by
Mira
Telerik team
Jon
Top achievements
Rank 1
Share this question
or