Article View: borland.public.cppbuilder.database.ado
Article #3681Re: Sorting DBGrid
From: Ola Eriksen
Date: Thu, 04 Jul 2002 14:27
Date: Thu, 04 Jul 2002 14:27
44 lines
2251 bytes
2251 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:
<3d246078_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!supernews.com!news.cs.utwente.nl!newshunter!cosy.sbg.ac.at!newsfeed.media.kyoto-u.ac.jp!newsfeed01.sul.t-online.de!t-online.de!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 08:14:16 PST 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 Lines: 45 NNTP-Posting-Host: 130.78.143.1 Message-ID: <3d246078_1@dnews> X-Trace: dnews 1025794168 130.78.143.1 (4 Jul 2002 07:49:28 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!supernews.com!news.cs.utwente.nl!newshunter!cosy.sbg.ac.at!newsfeed.media.kyoto-u.ac.jp!newsfeed01.sul.t-online.de!t-online.de!dnews