Recent

Author Topic: arranging the record of dgrid in ascending and descending order.  (Read 2909 times)

iamtheatorres2408

  • New Member
  • *
  • Posts: 23
arranging the record of dgrid in ascending and descending order.
« on: February 23, 2019, 05:54:35 am »
 Good Day,
                  how can i arrange the content record of my dbgrid into ascending or descending order? thank you..Godbless

madref

  • Hero Member
  • *****
  • Posts: 1116
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: arranging the record of dgrid in ascending and descending order.
« Reply #1 on: February 23, 2019, 12:19:44 pm »
You can do that in your sql-statement
You would probably have something like
Code: SQL  [Select][+][-]
  1. SELECT * FROM SomeTable
Add for small to big
Code: SQL  [Select][+][-]
  1. SELECT * FROM SomeTable ORDER BY A_Field ASC
or from big to small
Code: SQL  [Select][+][-]
  1. SELECT * FROM SomeTable ORDER BY A_Field DESC
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Main Platform:
--------------
Mac OS X Tahoe 26.2
Lazarus 4.99 (rev main_4_99-3149-g7867f6275c) FPC 3.3.1 x86_64-darwin-cocoa

Windows 10 Pro
Lazarus 3.99 (rev cbfd80ce39)

hrayon

  • Full Member
  • ***
  • Posts: 121

Thaddy

  • Hero Member
  • *****
  • Posts: 18911
  • Glad to be alive.
Re: arranging the record of dgrid in ascending and descending order.
« Reply #3 on: February 23, 2019, 03:50:53 pm »
That doesn't make much sense for a db aware control....without a query that sorts. So the queries are the correct solution.
Recovered from removal of tumor in tongue following tongue reconstruction with a part from my leg.

madref

  • Hero Member
  • *****
  • Posts: 1116
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: arranging the record of dgrid in ascending and descending order.
« Reply #4 on: February 23, 2019, 10:59:31 pm »
That doesn't make much sense for a db aware control....without a query that sorts. So the queries are the correct solution.
I agree. If you do it with source code you have to do it every time you change something.
When you do it with your sql. You only have to do it once
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Main Platform:
--------------
Mac OS X Tahoe 26.2
Lazarus 4.99 (rev main_4_99-3149-g7867f6275c) FPC 3.3.1 x86_64-darwin-cocoa

Windows 10 Pro
Lazarus 3.99 (rev cbfd80ce39)

hrayon

  • Full Member
  • ***
  • Posts: 121
Re: arranging the record of dgrid in ascending and descending order.
« Reply #5 on: February 24, 2019, 09:44:24 pm »
I use both approaches at the same time in a solution. This minimizes requests to the server. The data is already on the client side, you just need to rearrange it.

Thaddy

  • Hero Member
  • *****
  • Posts: 18911
  • Glad to be alive.
Re: arranging the record of dgrid in ascending and descending order.
« Reply #6 on: February 24, 2019, 10:02:12 pm »
That doesn't make much sense for a db aware control....without a query that sorts. So the queries are the correct solution.
I agree. If you do it with source code you have to do it every time you change something.
When you do it with your sql. You only have to do it once
It is even worse: remember the database itself is likely unordered.
- you read some number of records
- you sort those like in a normal grid.. (A..z, right?)
- user assumes he has read all A's!!!
- Next we read another chunk of the database
- you sort those like in a normal grid.. (A..z, right? Again)
- Guess what? there are more things that start with A and that is EXACTLY what a simple user does not understand.
- <sorry, but such things make me <grumpy  >:D >:D >:D>>

Stick to queries, even if you have a local copy use a TBufDataset in that case.
Recovered from removal of tumor in tongue following tongue reconstruction with a part from my leg.

 

TinyPortal © 2005-2018