Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, November 29, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - Controls
Forum to discuss usage & tips for SalesLogix controls and other 3rd party ActiveX controls. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to Controls | New ThreadView:  Search:  
 Author  Thread: How to sort a column of datagrid by integer rather than character
Jordan
Posts: 61
 
How to sort a column of datagrid by integer rather than characterYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Nov 09 3:49 PM
I had a grid "myGrid" and populated it programmatically through

Set colSchoolID = myGrid.Columns.Add(0)
colSchoolID.FieldName = "SchoolID"
colSchoolID.Caption = "SchoolID"

Set colLogins = myGrid.Columns.Add(0)
colLogins.FieldName = "Logins"
colLogins.Caption = "Logins"
colLogins.FormatType = 2 'Set the FormatType of the column as integer

I created a recortset "myRS" by "SELECT SchoolID, SUM(Login) AS Logins FROM myTable GROUP BY SchoolID"

and then:

Set myGrid.Recordset = myRS
myGrid.Refresh

The grid dispalyed well. But cilcking the header of the coulmn "Logins", I got

SchoolID Logins
1 0
2 123
3 5

It looked like the grid was sorted by character instead of integer. The correct result that I need is:
SchoolID Logins
1 0
3 5
2 123

What did I miss?

Thanks in advance.
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: How to sort a column of datagrid by integer rather than characterYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Nov 09 7:02 AM
In your SQL statement (script it and at runtime place it in the grid's .SQL.TEXT property) Cast your string field as int in your SELECT field clause...

SELECT A1.ACCOUNTID,
CAST(A2.STRINGFIELD as INT) A2_STRINGFIELD...
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/29/2024 7:04:03 PM