Sort as number, not as text

Stimulsoft Reports.NET discussion
Post Reply
incognito_gbg
Posts: 23
Joined: Wed May 30, 2007 4:15 am

Sort as number, not as text

Post by incognito_gbg »

I have a report where I want a databand to be sorted by a number-column.
The datasource in the stimulreport is generated from an xml-schema, to which a xml-file is bound duringruntime.
The valuetype of the number in the xml-schema is assigned as

But when I run it, the numbers come out in orders like:

1
10
17
2
24
3
35


instead of

1
2
3
10
17
24
35

How should I solve this?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Sort as number, not as text

Post by Edward »

Please check the type of the Column in the Designer. Please change type with right-click on the appropriate column and choose Edit from the context menu.

When it is not possible to change the type of the Column, please do the trick: Sorting via GroupBand. Place a GroupBand before DataBand and in Condition of the Group type something Like this:

{int.Parse(MyDataSource.MyColumn.ToString())}

Thank you.
incognito_gbg
Posts: 23
Joined: Wed May 30, 2007 4:15 am

Sort as number, not as text

Post by incognito_gbg »

I have checked the column in the designer, and it is set as "byte".

Tried to put the code you posted in a new groupheader below my existing one, but that just messed the report up.
EDV Gradl
Posts: 228
Joined: Sat Jun 17, 2006 9:50 am
Location: Germany

Sort as number, not as text

Post by EDV Gradl »

Maybe setting the sort option to this could help:

MyColumn.ToString().PadLeft(10,'0')

Hope that helps,

Marco
incognito_gbg
Posts: 23
Joined: Wed May 30, 2007 4:15 am

Sort as number, not as text

Post by incognito_gbg »

Hmm.........I cant find where I set the sortoption with code.....
EDV Gradl
Posts: 228
Joined: Sat Jun 17, 2006 9:50 am
Location: Germany

Sort as number, not as text

Post by EDV Gradl »

If that does not work add a caluculated column with PadLeft.. and set the data to be sorted by this new column.

Marco
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Sort as number, not as text

Post by Vital »

Please send your report to support [at] stimulsoft [dot] com.

Thank you.
Post Reply