1. #11
    Sencha User
    Join Date
    Oct 2007
    Location
    Norway
    Posts
    21
    Vote Rating
    0
    egs is on a distinguished road

      0  

    Default


    Hmm.. It might be me not getting this, but I'll try to explain it once more.

    If you take a look at the picture bellow, you'll see a grid using a GroupingView.
    The groupField property of the GroupingStore is set to the title column.

    As a result of this the grid is grouped by the title field.

    Now, I would like groups to be sorted on the "Group Count". To get the number of documents/rows in each group I use: values.rs.length

    Code:
    view: new Ext.grid.GroupingView({					
    					forceFit:true,
    					hideGroupedColumn: true,
    					startCollapsed: true,
    					groupTextTpl: '{text}  ({[values.rs.length]} {[values.rs.length > 1 ? "Reads" : "Read"]})'
    			}),
    In the picture you can see that groups are grouped by title, but the "Group Count" is not sorted. I would like the group with 32 reads to be at top, and the group with 5 read to be at the bottom.

    The "Group Count" would be different depending on the column/field I choose to group by, and cannot then be a field in the GroupingStore.

    The big question is then: How can I Group By a spesific column using the groupField property, but then sort by the "Group Count" ?

    Grid Grouped by the Title field:


    Same grid, but sorted by the Read Date field:


    Thanks !

    Best regards,
    Petter

  2. #12
    Sencha User
    Join Date
    Mar 2008
    Posts
    58
    Vote Rating
    0
    johnstontrav is on a distinguished road

      0  

    Question question for Animal?

    question for Animal?


    Hi Animal,

    Quote Originally Posted by Animal View Post
    It's a function, you have to call it and it sorts by the fields you specify.
    I am trying to get your multi-sorting code working. Here is my call string:

    PHP Code:
    this.store.sortByFields([{field'date'direction'DESC'},{field'sta'direction'ASC'}]); 
    Nothing happens.

    here is my code structure:

    PHP Code:
    Ext.ns('myNS');

    myNS.myGrid Ext.extend(Ext.grid.EditorGridPanel, {
         
    border:false
        
    ,initComponent:function() {
            ....
            ....
            
    Ext.apply(this, {
                
    storethis.store
                
    ,loadMasktrue
                
    ,cmcm
                
    ....
                
            });
            
            
    Verigo.myGrid.superclass.initComponent.apply(thisarguments);
        
        } 
    // end of initComponent    
            
        
    ,onRender:function() {
        
            ....
        
        } 
    // end of function onRender
        
            
    }); 

    Ext.reg('myGrid'myNS.myGrid); 
    I have tried calling sortByFields in the initComponent and the onRender function without success. Can you give me any assistance?

    Cheers,
    Trav.

  3. #13
    Sencha User
    Join Date
    Jun 2009
    Posts
    33
    Vote Rating
    0
    imnilesh is on a distinguished road

      0  

    Exclamation [Ext 3.0]Multi-column sort - needs a refresh ?

    [Ext 3.0]Multi-column sort - needs a refresh ?


    Thanks Christian, Animal.
    Above sortData function works fine for me in Ext 3.0. Though the 'datachanged' event is generated my grid is not refreshing the sort data. My code:

    Code:
    Ext.override(Ext.data.Store, {
      
        sortData : function(f, direction){
    // a test sort info
     var multipleSortInfo = [{field: 'number', direction: 'ASC'}, {field: 'name', direction: 'DESC'}];
     direction = direction || 'ASC';
     
     var st = this.fields.get(field).sortType;
     
     var fn = function(r1, r2) {
      var ret = 0;
      for (i = 0; (multipleSortInfo !== undefined && ret == 0 && i < multipleSortInfo.length); i++) {
       var v1 = st(r1.data[field]), v2 = st(r2.data[field]);
       var x1 = r1.data[multipleSortInfo[i].field], x2 = r2.data[multipleSortInfo[i].field];   
       var dir = (direction != multipleSortInfo[i].direction) ? direction
         .toggle("ASC", "DESC") : direction;
       ret = (x1 > x2) ? 1 : ((x1 < x2) ? -1 : 0);
       if (dir == 'DESC')
        ret = -ret;
      };
      return ret;
     };
     
     this.data.sort(direction, fn);
     if (this.snapshot && this.snapshot != this.data) {
      this.snapshot.sort(direction, fn);
     }
    }
    Am I missing anything here ?

  4. #14
    Ext User
    Join Date
    Oct 2009
    Posts
    3
    Vote Rating
    0
    Dusted is on a distinguished road

      0  

    Default


    Hi guys,

    Egs, have you found a solution to ordering by the group count as I am trying to do the same thing.

    I am producing a list of people and the forum posts they have made and I would like to order by the number of posts. I am grouping on the name and I am also bringing back the number of times they have posted but it will not let me order by that number, it is still ordering by the name. I have tried using both sortInfo and store.setDefaultSort but the grid is still sorting by the name.

    Any ideas?

  5. #15
    Ext User
    Join Date
    Oct 2009
    Posts
    3
    Vote Rating
    0
    Dusted is on a distinguished road

      0  

    Default


    For those of you wondering how this is done, if you set the remoteGroup config option to true then you can specify your own grouping in the method you use to get the store, in my case a stored procedure. Using this you can order the on the DB side and handle any other re-ordering in the XHR call.

    Dusted

  6. #16
    Ext User
    Join Date
    Nov 2009
    Posts
    3
    Vote Rating
    0
    yaminih is on a distinguished road

      0  

    Default Require Custom Sorting in GridPanel

    Require Custom Sorting in GridPanel


    Hi,
    I am facing a similar issue. I have 3 columns - Period,Name and Type. Type can be 'Low','Medium','High'. However, when I click on Sort Asc in the header, I want the display as follows:
    Low
    Medium
    High
    which is not necessarily alphabetical order.
    Is there any way to define custom sorting. I tried as follows but doesnt work:

    var config = {
    sortableField: 'Type.Name'
    };
    Ext.apply(
    this, {
    store:
    new Ext.data.Store({
    reader:
    new Ext.data.JsonReader(
    {
    id:
    'Id'
    },
    Ext.data.Record.create([
    { name:
    'Id', mapping: 'Id' },
    { name:
    'ReportingPeriod.Name', mapping: 'ReportingPeriod.Name' },
    { name:
    'Name', mapping: 'Name' },
    { name: 'Type.Name', mapping: 'Type.Name', sortType: this.sortTypes }
    ])
    )
    }),
    columns: [
    { header:
    "Id", width: 20, sortable: true, dataIndex: 'Id', hidden: true },
    { header:
    "Period", width: 175, sortable: true, dataIndex: 'ReportingPeriod.Name' },

    { header: "Name", width: 125, sortable: true, dataIndex: 'Name', minWidth: 100 },
    { header:
    "Type", width: 125, sortable: true, dataIndex: 'Type.Name', minWidth: 100 }
    ],
    height: 150,
    width: 400,
    autoScroll:
    true,
    closable:
    true,
    sm:
    new Ext.grid.RowSelectionModel({
    singleSelect:
    true,
    listeners: {
    rowselect:
    function(sm, rowidx, rec) {

    }
    }),
    viewConfig: {
    forceFit:
    true
    }
    });


    ----other code--,

    sortTypes:
    function(value) {
    switch (value.toLowerCase()) {
    case'Low':
    return 1;
    case'Medium':
    return 2;
    case'High':
    return 3;

    }
    return 4;
    },


    Any help is appreciated..Thanks in advance..

  7. #17
    Sencha User
    Join Date
    Jun 2009
    Posts
    33
    Vote Rating
    0
    imnilesh is on a distinguished road

      0  

    Default typo in sortTypes ??? always returns 4 ??

    typo in sortTypes ??? always returns 4 ??


    Do the function always returning 4 ??

    sortTypes: function(value) {
    switch (value.toLowerCase()) {
    case'Low': ====> should it be 'low' here ?
    return 1;
    case'Medium': ====> medium
    return 2;
    case'High': ====> high
    return 3;

    }
    return 4;
    },

  8. #18
    Ext User
    Join Date
    Oct 2009
    Posts
    3
    Vote Rating
    0
    Dusted is on a distinguished road

      0  

    Default


    @yaminih

    Are you loading the data into the grid using a query? In my case i was and gave high, medium and low the Id's 1,2 and 3 so that i could order them as you are trying.

    This only works if you are using a database call though...

  9. #19
    Ext User
    Join Date
    Mar 2010
    Posts
    8
    Vote Rating
    0
    suchitratata is on a distinguished road

      0  

    Default


    Animal,

    I just wanted to check if I can use your sortByFields() in Ext 3.0 as well. If so, where do I call that function? I tried to call it in sortChange listener of my gridpanel but it goes into endless recursion

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar