EasyCFM.COM ColdFusion Forums / Coding Help! / Stupid # question

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Stupid # question

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

MIGhunter
04-17-2010 @ 11:11 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 570
Joined: Apr 2006

Really stupid ? here.  How do I set up either a cgdrid or my database so that it sorts numbers numerically instead of by the digit. i.e.
94.0
91.0
74.0
8.0
6.0

Instead what I am getting is:
94.0
91.0
8.0
74.0
6.0

cfSearchin
04-18-2010 @ 12:34 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 608
Joined: Feb 2008

It is sorting as a string, not a number. Specify the value type

<cfgridcolumn type="numeric" ....>

This message was edited by cfSearchin on 4-18-10 @ 12:35 AM

Webmaster
04-18-2010 @ 12:55 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

If you want to do it in the database; then change the
field type to image or cast() at time of retrieval.

if you are using MS SQL you could do this:

select cast(fieldName as int) as numericalField
from tableName
order by numericalField

Just a sample.

Let me know if you have any questions.

Pablo Varando
Senior Application Architect
EasyCFM.COM, LLC.

904.483.1457 \\ mobile
webmaster@easycfm.com \\email

\m/ (>.<) \m/
--- rock on ---

cfSearchin
04-18-2010 @ 1:54 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 608
Joined: Feb 2008

Yes, you are right. I did not realize their column type was not numeric. Changing the column type is the best solution.

MIGhunter
04-18-2010 @ 2:19 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 570
Joined: Apr 2006

it's a php program I'm pulling information from.  I looked up the tables and the fields are "float".

cfSearchin
04-19-2010 @ 7:18 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 608
Joined: Feb 2008

Well, a decimal type column worked fine for me. So I would assume float would as well. I am not sure why it is not working for you. Did you try explicitly setting the column type in your grid?

<cfgridcolumn type="numeric" ....>

?

MIGhunter
04-19-2010 @ 9:25 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 570
Joined: Apr 2006

yeah, I did that like you suggested and it seems to be better now, thanks.


Website Designed and Developed by Pablo Varando.