Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User
    Join Date
    Nov 2008
    Posts
    61
    Vote Rating
    0
    SunWuKung is on a distinguished road

      0  

    Default grid column header menu - sort columns alphabetically

    grid column header menu - sort columns alphabetically


    Hi,
    In my grid I have many columns most of which are not shown by default.
    When making a column visible it would be easier to find the column in the header menu if I could order the list alphabetically (I do not want to change the order in which they appear in the grid, just sort the column list).

    Could somebody tell me how to do that?
    Thanks for the help.
    SWK

  2. #2
    Ext JS Premium Member
    Join Date
    Jul 2009
    Posts
    239
    Vote Rating
    2
    stephen.friedrich will become famous soon enough

      0  

    Default


    See the code below.
    I searched for "enableHdMenu" in the ext sources, found a reference in GridView to this.colMenu, then found the method beforeColMenuShow in which the column menu items are created.
    You can always replace such a method with Ext.override.
    You need to re-examine each overriden method whenever you upgrade ExtJS to a new version, though!
    This is tested with ExtJS 3.2.2

    PHP Code:
        Ext.override(Ext.grid.GridView, {
                         
    beforeColMenuShow : function() {
                             
    // Copy necessary data for the column items to an array
                             
    var cm this.cm,  colCount cm.getColumnCount();
                             var 
    sortedColumns = new Ext.util.MixedCollection();
                             for (var 
    0colCounti++) {
                                 if (
    cm.config[i].hideable !== false) {
                                     var 
    columnId cm.getColumnId(i);
                                     
    sortedColumns.add(columnId,
                                                       {
                                                           
    idcolumnId,
                                                           
    headercm.getColumnHeader(i),
                                                           
    isHiddencm.isHidden(i)
                                                       });
                                 }
                             }
                             
    // Sort the column data by column header texts
                             
    sortedColumns.sort('ASC',
                                                function(
    ab){
                                                    var 
    headerA a.header.toLocaleLowerCase();
                                                    var 
    headerB b.header.toLocaleLowerCase();
                                                    return 
    headerA.localeCompare(headerB)
                                                });

                             
    this.colMenu.removeAll();

                             
    // finally create the menu items from the sorted column data
                             
    sortedColumns.each(function(columnData) {
                                 
    this.colMenu.add(new Ext.menu.CheckItem({
                                                                             
    itemId'col-' columnData.id,
                                                                             
    textcolumnData.header,
                                                                             
    checked: !columnData.isHidden,
                                                                             
    hideOnClick:false
                                                                         
    }));
                             }, 
    this);
                         }

                     }); 
    ExtJS 4 plugins:
    varheaders - short/normal/long column header
    clearbutton - mouseover clear button in text field
    Blog: fit4dev
    ExtJS User Group Hamburg

  3. #3
    Sencha User
    Join Date
    Nov 2008
    Posts
    61
    Vote Rating
    0
    SunWuKung is on a distinguished road

      0  

    Default


    wow,
    many thanks for this, I will try it when I return after Eastern.

    Thanks again.
    SWK

  4. #4
    Sencha User
    Join Date
    Nov 2008
    Posts
    61
    Vote Rating
    0
    SunWuKung is on a distinguished road

      0  

    Default


    hi,
    this works for me with Ext 3.4

    I have added a short function to handle accented characters better (for my purpose).

    Code:
    String.prototype.strip = function() {
      var translate_re = /[ŠšĐđŽžČčĆćÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕüÜűőŐŰ]/g;
      var translate = {
        'Š':'S', 'š':'s', 'Đ':'Dj', 'đ':'dj', 'Ž':'Z', 'ž':'z', 'Č':'C', 'č':'c', 'Ć':'C', 'ć':'c', 'À':'A', 'Á':'A', 'Â':'A', 'Ã':'A', 'Ä':'A', 'Å':'A', 'Æ':'A', 'Ç':'C', 'È':'E', 'É':'E', 'Ê':'E', 'Ë':'E', 'Ì':'I', 'Í':'I', 'Î':'I', 'Ï':'I', 'Ñ':'N', 'Ò':'O', 'Ó':'O', 'Ô':'O', 'Õ':'O', 'Ö':'O', 'Ø':'O', 'Ù':'U', 'Ú':'U', 'Û':'U', 'Ü':'U', 'Ý':'Y', 'Þ':'B', 'ß':'Ss', 'à':'a', 'á':'a', 'â':'a', 'ã':'a', 'ä':'a', 'å':'a', 'æ':'a', 'ç':'c', 'è':'e', 'é':'e', 'ê':'e', 'ë':'e', 'ì':'i', 'í':'i', 'î':'i', 'ï':'i', 'ð':'o', 'ñ':'n', 'ò':'o', 'ó':'o', 'ô':'o', 'õ':'o', 'ö':'o', 'ø':'o', 'ù':'u', 'ú':'u', 'û':'u', 'ý':'y', 'ý':'y', 'þ':'b', 'ÿ':'y', 'Ŕ':'R', 'ŕ':'r', 'ü':'u', 'Ü':'U', 'ű':'u', 'ő':'o', 'Ő':'o', 'Ű':'U'
      };
        return (this.replace(translate_re, function(match){
            return translate[match];})
        );
    };
    
    ..... than in the override .........
    function(a, b){
                                   var headerA = a.header.toLocaleLowerCase().strip();
                                   var headerB = b.header.toLocaleLowerCase().strip();
                                   return headerA.localeCompare(headerB)
                               });
    .......
    Many thanks for the help.
    SWK

Similar Threads

  1. Replies: 4
    Last Post: 8 Aug 2012, 12:11 AM
  2. GXT Grid, How to sort the column menu Header Item
    By gxtyas in forum Ext GWT: Discussion
    Replies: 1
    Last Post: 14 Oct 2010, 9:20 AM
  3. Grid Header Columns Not Resizing After Sort
    By bgoodin in forum Ext GWT: Discussion
    Replies: 1
    Last Post: 23 Sep 2009, 10:57 AM
  4. Can you change grid column header menu for individual columns?
    By NegrilLover in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 26 Jun 2008, 5:38 PM

Thread Participants: 1