Article View: borland.public.cppbuilder.database.ado
Article #3673Re: Sorting DBGrid
From: Ola Eriksen
Date: Thu, 04 Jul 2002 14:27
Date: Thu, 04 Jul 2002 14:27
44 lines
2281 bytes
2281 bytes
It's working now :) thanks! "J.Steinecker" wrote: > 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:
<3D245B43.3549AA84@callcom.no>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!supernews.com!iad-peer.news.verio.net!news.verio.net!news.maxwell.syr.edu!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnewsReferences:
<1103_1025773874@ola> <3d244532_2@dnews>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:33:26 PST Message-ID: <3D245B43.3549AA84@callcom.no> Date: Thu, 04 Jul 2002 15:27:15 +0100 From: Ola Eriksen <ola@callcom.no> X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.database.ado Subject: Re: Sorting DBGrid References: <1103_1025773874@ola> <3d244532_2@dnews> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 193.69.252.248 X-Trace: dnews 1025789300 193.69.252.248 (4 Jul 2002 06:28:20 -0700) Lines: 45 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!supernews.com!iad-peer.news.verio.net!news.verio.net!news.maxwell.syr.edu!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews