This is a migrated thread and some comments may be shown as answers.

Sort String as Integer

2 Answers 56 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 25 Jan 2012, 02:46 PM
Hello.

What is the easiest way to achieve the following:
I've got a data-bound chart and a property Value of type String. In some cases this string is a numeric value. How can I switch the sort algorithm so that I get 1, 5, 12 and not 1, 12, 5, ... I am using SortDescriptors but unfortunately there is nothing like a SortAsInteger property :) But as this is a very common scenario I hope that it is supported out of the box.

Thanks a lot and have a good day,
Tim.

2 Answers, 1 is accepted

Sort by
0
Accepted
Petar Marchev
Telerik team
answered on 30 Jan 2012, 08:48 AM
Hi,

No, such a behavior is not supported out-of-the-box.

The easiest way to achieve this is to create a new property in your underlying object that parses the string to an int and use that new property for your XCategory(or XValue). 

Regards,
Petar Marchev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Tim
Top achievements
Rank 1
answered on 30 Jan 2012, 12:48 PM
Ok. Thanks for your answer. I thought there would be a "cleaner" way to do it...
All the best and thanks again,
Tim.
Tags
Chart
Asked by
Tim
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Tim
Top achievements
Rank 1
Share this question
or