View Full Version : Sorting Number items in Grid
andulek
03-21-2009, 02:09 PM
Good evening,
i have a little question, is there a way to implement my own function
for sorting items in Grid objects? or maybe a simplier solution for sorting numbers? because if there are numbers it sorts them wrong like strings in such order:
1
10
100
2
... and so on..
any help would be much appreciated :)
presidente
03-21-2009, 11:19 PM
You have to store the numbers with leading ceros.
instead of 1 you have to store 001. Or if you are working with larger numbers, you have to use more leading ceros.
andulek
03-22-2009, 05:09 AM
yes i know this method, but i dont want to do it like this, because it will slow down whole process, as this field is SQL autonumber, so EVERY time i open database i must add leading zeros. its not a solution. any other ideas?
presidente
03-22-2009, 06:20 AM
All you put in zhe grid is handeld like text.
So you have to put leading zeros.
But i think you can sort it in the table and read the sorted table into the grid. This normaly must work.
webultra
03-26-2009, 12:45 PM
I don't how are you reading the values from your table (I supposed u are using "Select * from Table1") , but u can read the values already sorted from the sql table in descending or ascending order.
Use the following query: "Select * from Table1 ORDER BY Column"
Column = The column of your autonumbered values.
The default sort order is DESC (descending), but you can sort the items in ascending order with this: "Select * from Table1 ORDER BY Column ASC"
Let me know if it worked for you.
What am I doing wrong? I cannot get the leading zero solution to work. Also pulling from SQL database.
http://www.indigorose.com/forums/attachment.php?attachmentid=8429&stc=1&d=1250306589
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.