Setting Order By in Browse Dialog Search Results


Author
Message
Govinda Berrio
Govinda Berrio
StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)
Group: StrataFrame Users
Posts: 94, Visits: 481
Hello all, 

I have a browse dialog that is querying on a table with 10s of thousands of records. 
When the user searches, with criteria selected, there are a lot of results. But, I have the Browse Dialog set to only get TOP 1000, to improve responsiveness.

My intention is to have the search results return the latest records first, sorted by the added_date field. So query I would need the Browse Dialog to perform is something like this: SELECT TOP 1000 * ... ORDER BY added_date DESC

When I set the sort order in the SearchFields editor, it sorts the records that it gets back from a regular query with no Order By clause, so the user is not getting the latest records. They're getting the TOP 1000 records in the order that they are in the table. 

When I set the BrowseDialog.OrderBy property, I can put the field there, but I can't specify "DESC"; I get the SQL error, "Invalid column name 'added_date DESC'."

Could someone please help me display the latest records in the Browse Dialog.

Thank You,
Govinda
Replies
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Govinda,

You are welcome.

I spend sometime with the BD and was able to duplicate your easy right away and yes you are right about the OrderByFields property.  I know you can use the BD with a Stored Procedure and a view, but probably if your don't have too many search fields, you can simply build your own search feature.

Here is what I do today....
  • I use DevExpress controls, specially their grid, it is very powerful, flexible and super fast.
  • In most cases I will always show the grid with many records so end user select the one they need.
  • I create a View to be used with the grid and then a Stored Procedure (SP) to grab the data for the view.
  • Once your SP is working as expected then create your search fields controls and then call your SP to load the grid.
I know this is not a generic method as with the BD, but I have full control of the search, specially optimizing it and showing the data the way I want with the DevExpress grid.  See the attached image to see how it looks and if you need more details, just let me know.

Edhy Rijo

Attachments
CustomSearchForm.png (253 views, 159.00 KB)
Govinda Berrio
Govinda Berrio
StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)
Group: StrataFrame Users
Posts: 94, Visits: 481
That is a good strategy, Edhy, but I can't spend the time converting it over. 
I did go ahead with the idea that I had and it worked. See the code below.

private void JobTicketBD_BeforeSearchExecuted(object sender, BrowseDialogBeforeSearchExecutedEventArgs e)
{
    e.QueryInfo.OrderByFields.Add("add_date_descending");
    e.QueryInfo.Tokens.Add("add_date_descending", "add_date DESC");
}


Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Govinda
Awesome and simple!!!

Thanks for sharing this idea!!!

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search