Print Page | Close Window

Sort the column to numeric values​​?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=18655
Printed Date: 25 February 2025 at 1:25pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Sort the column to numeric values​​?
Posted By: g.novi
Subject: Sort the column to numeric values​​?
Date Posted: 13 July 2011 at 7:27am
How to sort the column to numeric values​​?
A report column contains numeric values ​​but the sort does not work.

Now sort in this way:
   10,00
 100,00
   12,00
   13,00   
   20,00
     3,00
 
I would like this result:
     3,00
   10,00
   12,00
   13,00   
   20,00
 100,00

Thank's to all
   



Replies:
Posted By: Aaron
Date Posted: 13 July 2011 at 8:13am
Hi,
 
Did add numeric values as text or as Integer, Long, Double? RC supports type sorting. If you added it as text it sorts like MS explorer does,   1,10,11,2,3,4,5 etc, etc
 
If you are able to convert text to type you need it will work, if you can't just set .SortPriority when adding items to RC  
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: g.novi
Date Posted: 13 July 2011 at 10:21am
Originally posted by Aaron Aaron wrote:

Hi,
Did add numeric values as text or as Integer, Long, Double? RC supports type sorting. If you added it as text it sorts like MS explorer does,   1,10,11,2,3,4,5 etc, etc
 
If you are able to convert text to type you need it will work, if you can't just set .SortPriority when adding items to RC  

Hi,
maybe because I insert formatted numbers? (Ex: 12 in 12,00).
How do I get formatted numbers and correct sort?
Thank You.



Posted By: g.novi
Date Posted: 13 July 2011 at 10:52am
Originally posted by Aaron Aaron wrote:

...
If you are able to convert text to type you need it will work, if you can't just set .SortPriority when adding items to RC  

If I convert text into Double type it works, but the number will not be formatted!
How can I do!?

Thank's


Posted By: Aaron
Date Posted: 13 July 2011 at 4:41pm

Originally posted by g.novi g.novi wrote:

[...]
If I convert text into Double type it works, but the number will not be formatted!
How can I do!?
[...]

OK, you solved that part...

You can't use .Format property because it will be "converted" to a string and it doesn't sort properly anymore. Best way is to use custom format in BeforeDrawRow event something like this:

in FormLoad (or wherever you initialize RC) set:
wndReportControl.SetCustomDraw xtpCustomBeforeDrawRow

 
Private Sub wndReportControl_BeforeDrawRow(ByVal Row As XtremeReportControl.IReportRow, ByVal Item As XtremeReportControl.IReportRecordItem, ByVal Metrics As XtremeReportControl.IReportRecordItemMetrics)
 
    Row.Record.Item(0).Caption = Format(Row.Record.Item(0).Value, "##0.#0")

End Sub

Hope this helps Wink
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: g.novi
Date Posted: 14 July 2011 at 9:52am
Originally posted by Aaron Aaron wrote:

...

Private Sub wndReportControl_BeforeDrawRow(ByVal Row As XtremeReportControl.IReportRow, ByVal Item As XtremeReportControl.IReportRecordItem, ByVal Metrics As XtremeReportControl.IReportRecordItemMetrics)

    Row.Record.Item(0).Caption = Format(Row.Record.Item(0).Value, "##0.#0")

End Sub


Very well !!!

Thank you




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net