🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #3672

Re: Sorting DBGrid

#3672
From: J.Steinecker
Date: Thu, 04 Jul 2002 12:58
36 lines
2068 bytes
Hi,

if you use a TQuery as DataSet you can search the SQL->Text AnsiString for
an ORDER BY.

If you cannot find an ORDER BY then you can append one with the
column->FieldName.
If you find an ORDER BY then you can do different ways. In case it is the
same column I change the sort order from ascending to descending or vice
versa. In the other case you can change the sort column.
After that I close and reopen the manipulated query to do the sorting.

You have to think about some problems. You can have comments in the SQL
statement what you have to take into consideration on searching for the
ORDER BY. If you use calculated fields in your query then you get the
gridname in the OnTitleClick event, but on which column is to sort?
So I provided a method to produce an additional list which makes a mapping
between gridcolumns and querycolumns.

HTH
Juergen

"Ola Eriksen" <ola@callcom.no> schrieb im Newsbeitrag
news:1103_1025773874@ola...
> Hello!
>
> A simple question I guess :)
>
> Can anyone help me with some code so that I can sort the TDBGrid by the
field the user selects.
> I've activated the OnTitleClilck event, but I've not managed to write a
code that works :(
>
> Thanks!
>
>
Technical Details
Message-ID: <3d244532_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-03!sn-xit-06!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews
References: <1103_1025773874@ola>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,6f893f24f32b7eae
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2002-07-04 06:03:21 PST
From: "J.Steinecker" <jsteinecker@gmx.de>
Newsgroups: borland.public.cppbuilder.database.ado
References: <1103_1025773874@ola>
Subject: Re: Sorting DBGrid
Date: Thu, 4 Jul 2002 14:58:45 +0200
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 217.225.22.157
Message-ID: <3d244532_2@dnews>
X-Trace: dnews 1025787186 217.225.22.157 (4 Jul 2002 05:53:06 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-03!sn-xit-06!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews