DBGrid rows order

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jota
Posts: 34
Joined: Tue 22 Nov 2011 19:21

DBGrid rows order

Post by jota » Wed 27 Nov 2013 10:09

Hello.

I want to alphabetically order the rows of a dbgrid. The information is loaded from a 'TDataSource' that takes information from a 'tunitable'.

In 'tunitable' I define the property OrderFiels with alphabetical field name, but the information isn´t ordered in dbgrid.

What am I doing wrong?

Thanks in advance.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: DBGrid rows order

Post by AlexP » Wed 27 Nov 2013 12:37

Hello,

Please specify the name of the database you are working with. Please also check that the query SELECT * FROM TABLE ORDER BY FIELD (that is generated when setting OrderFiels) return the correct results when using the native database tools.

jota
Posts: 34
Joined: Tue 22 Nov 2011 19:21

Re: DBGrid rows order

Post by jota » Wed 27 Nov 2013 13:30

Hello

I´m working with SQLite version 3.

My select: 'SELECT * FROM TABLE ORDER BY ALPH-FIELD-NAME ASC'

Select return is correct.

Thanks

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: DBGrid rows order

Post by AlexP » Fri 29 Nov 2013 12:54

Hello,

We cannot reproduce the problem, please send the DB file to alexp*devart*com

jota
Posts: 34
Joined: Tue 22 Nov 2011 19:21

Re: DBGrid rows order

Post by jota » Fri 29 Nov 2013 13:52

Hello

I think I've solved with the following correction:

I define property IndexFieldNames with alphabetical field name (I had previously defined another field in this property) and property OrderFiels empty.

In this case the select return is correct (dbgrid rows appears so ordered ascending alphabetical).

Thanks

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: DBGrid rows order

Post by AlexP » Fri 29 Nov 2013 14:58

Hello,

This is correct behaviour. As I wrote you before, when enabling the OrderFields property, a corresponding Order By section with specified fields is added to the query - and the query is sent to the server; the server returns a correctly sorted DataSet. However, if the IndexFieldNames is set, the obtained DataSet will be sorted locally by the fields specified in the IndexFieldNames property - and the sorting retrieved from the server will be modified. Therefore simultaneous setting of these two properties won't work correctly.

Post Reply