IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

February Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyPascal and Delphi Coding BoardDelphi Single User Apps Topic   Print This    All Groups  

Sorting tables

Sorting tables in Delphi Single User Apps topic (part of our Pascal and Delphi Coding group).

Quick Search: Sorting   Sorting tables  
ShikidoFu
 (Inactive)
Singapore
Hihi
newbie here...
can someone tell me if the is a way to sort a table component according to a secondary field?
i've tried using a query but i can't edit the sorted data.
is there any other way out?
 Posted 19 years ago (Thread Starter)
Comment Quote
About ShikidoFu -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #2254, 2 replies
Thread Started 5/23/2001 4:38:00 AM
View Counter=1310
Last Reply Posted 5/29/2001 1:37:00 AM)
Location=Singapore  
Joined=19 years ago   MB Posts=5  
Most Recent Post
ShikidoFu
 (Inactive)
Singapore
thank you very much
 Posted 19 years ago (Thread Starter)
Comment Quote
About ShikidoFu -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #2300 (Level 1.1)  Reply to 2254
Thread Started 5/29/2001 1:37:00 AM
View Counter=2
Location=Singapore  
Joined=19 years ago   MB Posts=5  
Scott Wehrly
Prestwood IT
 (Inactive)
Las Vegas, NV USA
Using the existing TTable component, you can have the table's records sorted by the secondary field by adding an index on that field to the IndexName property of the TTable.

For example:


Let's say I have a Paradox table named CUSTOMER, which has a primary key field named CustID (INTEGER).

Now, let's say that I want to sort the table on the fields LAST_NAME and FIRST_NAME (both are type A25). I'd create a secondary index on the table for those two fields, and call it CustName.

In Delphi:

I would have a TTable component assigned to CUSTOMER.DB, and in the Object Inspector, I'd assign the following property:

IndexName=CustName

The name of the index (CustName) would appear in the drop-down list on that property.

I could have more than one index on the table, and assign them dynamically at runtime based on what I wanted to do with the records. I use this method all of the time to re-sort the records in a grid based on which column header the user clicked on. Now that

Another way to do this, without using named indexes, is to set the IndexFieldNames property to the field(s) you wish to sort on. I could have accomplished the same goal I showed above using the following code to re-sort the TTable at run-time:


with CustTable do
begin

DisableControls;
Active := False;
IndexFieldNames := 'LAST_NAME;FIRST_NAME';
EnableControls;
Active := True;
end;
 Posted 19 years ago
Comment Quote
About Scott Wehrly -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #2256 (Level 1.2)  Reply to 2254
Reply Posted 5/23/2001 6:04:00 AM
Location=Las Vegas, NV USA 
Joined=18 years ago   MB Posts=442   KB Posts=19  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1183A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #2254 Counter
1310
Since 4/2/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2020 Prestwood IT Solutions.   [Security & Privacy]