?
Solved

Sorting within a database grid

Posted on 1997-09-17
6
Medium Priority
?
171 Views
Last Modified: 2010-04-04
I want to be able to have the data listed in a dbGrid be sorted by one (or two) of the fields. The dbGrid's datasource comes from a table which has a master datasource.

I tried specifying the field name I wanted to sort by in the "IndexFieldNames" property, but had a "Index out of range" error.
0
Comment
Question by:BadBart
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1345398
Did you try SQL?
0
 

Author Comment

by:BadBart
ID: 1345399
The supervisor of the project does not regard SQL very highly as it takes a much longer time to process.

So, I'm only to use things such as Findkey() and FieldByName().
0
 
LVL 1

Expert Comment

by:anilms
ID: 1345400
Could you be more specific in telling us what type of database table you have (dbf or paradox) and what are the indexes you have created for the table. This would be more useful in getting a proper solution for your needs.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:ZifNab
ID: 1345401
I know this is a stupid question, but i'm going to ask it anyway :

When using IndexFieldNames you have to define as index field names in your table structure. Have you done this. Primary and secondary indexes???

Have fun,
c.u. ZifNab;

0
 
LVL 1

Accepted Solution

by:
jturpin earned 200 total points
ID: 1345402
Try using
   try
      .
      .
      .
   SomeName : String;
   YourTable.Close;
   YourTable.AddIndex(SomeName,'Field1;Field2',
      [ixExpression,ixDescending]);
   YourTable.IndexName:= SomeName;
   YourTable.Open;
      .
      ---Processing ---
      .
      .
   finally
      YourTable.Close;
      YourTable.DeleteIndex(SomeName);
      YourTable.IndexName:= '';
      YourTable.IndexDefs.Update;
   end;
0
 

Author Comment

by:BadBart
ID: 1345403
Sorry for the delay! Thanks heaps..!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month10 days, 2 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question