Hi, if I'm viewing a query result set in a grid and set
Query->IndexFieldNames="Field1";
the result set is ordered by Field1 and record position is maintained (as you would expect). If I then set
Query->IndexFieldNames="";
nothing happens. I could follow that with the command
Query->Refresh();
and that will reset the order to the default but, that often results in loss of record position.
Setting Query->IndexFieldNames="" does nothing
-
NoComprende
- Posts: 135
- Joined: Tue 09 Jan 2007 13:44
-
NoComprende
- Posts: 135
- Joined: Tue 09 Jan 2007 13:44
A way round this is
Query->IndexFieldNames=Query->GetOrderBy();
// above results in Query being sorted on default order with record position maintained
Query->IndexFieldNames="";
// does nothing but is a reminder that Query is sorted on default order
The only problem with the above solution is that a) GetOrderBy() may return an empty string (it also returns an incorrect result if the Query is sorted by a 'GROUP BY' clause as opposed to an 'ORDER BY' clause) and b) even if it doesn't, there's no guarantee the fields returned by GetOrderBy() will be present in the actual result set.
Query->IndexFieldNames=Query->GetOrderBy();
// above results in Query being sorted on default order with record position maintained
Query->IndexFieldNames="";
// does nothing but is a reminder that Query is sorted on default order
The only problem with the above solution is that a) GetOrderBy() may return an empty string (it also returns an incorrect result if the Query is sorted by a 'GROUP BY' clause as opposed to an 'ORDER BY' clause) and b) even if it doesn't, there's no guarantee the fields returned by GetOrderBy() will be present in the actual result set.
-
NoComprende
- Posts: 135
- Joined: Tue 09 Jan 2007 13:44