Gridpanel custom sorting

Page 1 of 2 12 LastLast
  1. #1

    Gridpanel custom sorting

    I have gridpanel and sortable column. Can I implement custom sorting for columns to sort column by ID or by some other column? How?

    Thanks!
  2. #2
  3. #3
    Thanks it helped me but now I have performance problems :(
  4. #4
    How did you implement CustomSort? How much rows you bind to the grid?
  5. #5
                var mySortType = function(value) {
                    #{StoreSortOP}.data.each(function(item, index, totalItems) {
                        if(value == item.data["OP_Name"]) {
                            value = #{StoreSortOP}.data.items[index].data["OP_ID"];
                            return false; //break each loop
                        }
                    });  
                    return value;
                }
    I use this code because I need to sort column "OP_Name" by value "OP_ID".
    On one page I have 50 rows. All rows about 2000. But that number is variable.
  6. #6
    var mySortType = function(value, record) {
        return record.data["OP_ID"];
    };
  7. #7
    record is undefined
  8. #8
    I call function here:
    <CustomSortType Fn="mySortTypeOP" />
  9. #9
    Try to add the following fix to the page
    Ext.data.Store.override({
    createSortFunction: function(field, direction) {
            direction = direction || "ASC";
            var directionModifier = direction.toUpperCase() == "DESC" ? -1 : 1;
    
    
            var sortType = this.fields.get(field).sortType;
    
    
            //create a comparison function. Takes 2 records, returns 1 if record 1 is greater,
            //-1 if record 2 is greater or 0 if they are equal
            return function(r1, r2) {
                var v1 = sortType(r1.data[field], r1),
                    v2 = sortType(r2.data[field], r2);
    
    
                return directionModifier * (v1 > v2 ? 1 : (v1 < v2 ? -1 : 0));
            };
        }
    });
  10. #10
    It is interesting that works for sorting :) , but I got error on page load:

    Microsoft JScript runtime error: 'Ext' is undefined
    Where to put that code? (Now it is inside this tags: <ext:XScript><script> ... </script></ext:XScript>)
    Last edited by geoffrey.mcgill; Jan 27, 2015 at 5:01 PM.
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Custom Grid Sorting
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 15
    Last Post: Oct 24, 2013, 4:15 AM
  2. [CLOSED] How to disable gridpanel sorting
    By digitek in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: Apr 30, 2013, 4:10 AM
  3. [CLOSED] Disabled Sorting in GridPanel
    By csharpdev in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 22, 2010, 1:22 PM
  4. Problem with GridPanel sorting
    By magisystem in forum 1.x Help
    Replies: 3
    Last Post: Sep 09, 2010, 1:35 PM
  5. [CLOSED] Sorting Disabled in GridPanel
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 07, 2010, 11:37 AM

Tags for this Thread

Posting Permissions