Page 1 of 1

DBGrid rows order

Posted: Wed 27 Nov 2013 10:09
by jota
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.

Re: DBGrid rows order

Posted: Wed 27 Nov 2013 12:37
by AlexP
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.

Re: DBGrid rows order

Posted: Wed 27 Nov 2013 13:30
by jota
Hello

I´m working with SQLite version 3.

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

Select return is correct.

Thanks

Re: DBGrid rows order

Posted: Fri 29 Nov 2013 12:54
by AlexP
Hello,

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

Re: DBGrid rows order

Posted: Fri 29 Nov 2013 13:52
by jota
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

Re: DBGrid rows order

Posted: Fri 29 Nov 2013 14:58
by AlexP
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.