Results 1 to 5 of 5

Thread: Sorting Numeric Text in Column

  1. #1
    Ext JS Premium Member
    Join Date
    Jan 2010
    Posts
    18

    Default Sorting Numeric Text in Column

    Hey All,

    Is there a way to sort numeric text in an appropriate fashion (and not like 10,109,21,240,3)?

    Thanks,

    SKH

  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    are you setting the field as type : 'INT" ?

  3. #3
    Ext JS Premium Member
    Join Date
    Jan 2010
    Posts
    18

    Default

    No...as a string...was kind of hoping there would be a way to handle this with a configuration option. I tried setting the sortType in the fields configuration object to 'asInt', but it had no effect.

  4. #4
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    try this simple sorter:


    function sortNumber(a,b) {
    return b - a;
    }

    var n = ["10", "5", "40", "25", "100", "1"];
    console.log(n.sort(sortNumber));

  5. #5
    Ext JS Premium Member
    Join Date
    Jan 2010
    Posts
    18

    Default

    Okay...where or how do I implement this sorter? I have a JsonStore with dates, alphanumeric data and numbers (all received as strings) that feeds a grid on a report page. I was able to get the dates to sort by setting the dateFormat property to "m/d/Y' within the JsonStore. Where or how do I configure this sorter to apply only to the number fields?

Similar Threads

  1. Sorting of numeric column in GridPanel
    By livinglegends in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 4 Dec 2010, 1:25 AM
  2. [2.2] Numeric column types cast blank values to 0
    By stouset in forum Ext 2.x: Bugs
    Replies: 4
    Last Post: 27 Feb 2009, 9:17 AM
  3. Numeric sorting in a grid?
    By doubleforte in forum Ext 2.x: Help & Discussion
    Replies: 9
    Last Post: 8 May 2008, 6:52 PM
  4. Disable column onclick sorting, but still allow sorting via column menu
    By Troy Wolf in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 26 Mar 2008, 9:39 AM
  5. Obtaining a column's numeric index from its data Index
    By cesarulo in forum Ext 1.x: Help & Discussion
    Replies: 15
    Last Post: 1 Jun 2007, 1:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •