Sort String as Integer

3 posts, 1 answers
  1. Tim
    Tim avatar
    114 posts
    Member since:
    Aug 2011

    Posted 25 Jan 2012 Link to this post

    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. Answer
    Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 30 Jan 2012 Link to this post

    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 >>

  3. DevCraft banner
  4. Tim
    Tim avatar
    114 posts
    Member since:
    Aug 2011

    Posted 30 Jan 2012 Link to this post

    Ok. Thanks for your answer. I thought there would be a "cleaner" way to do it...
    All the best and thanks again,
    Tim.
Back to Top