?
Solved

Sorting within a database grid

Posted on 1997-09-17
6
Medium Priority
?
175 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

649 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