tags:

views:

38

answers:

1

In my grid I want to set 3 buttons allowing the user to choose the cols to view

So I wrote this function; it's fast on chrome and safari, but it takes a lot of time on Firefox.

Where is the problem? Is there another way to do this?

function showHideCols(dcols){
            thisGrid = Ext.getCmp('myGrid')
            thisColModel = thisGrid.getColumnModel()
            var hiddenCols = thisColModel.getColumnsBy(function(c){
                if(c.hidden==true) return true;
                });

            var majCols = thisColModel.getColumnsBy(function(c){
                   if(c.id>17) return true;
                });

            var editCols = thisColModel.getColumnsBy(function(c){
                   if(c.id<18) return true;
                });

            switch(dcols){
                case 'maj' :
                Ext.each(majCols,function(f){
                    thisColModel.setHidden(f.id,false)
                 })

                 Ext.each(editCols,function(f){
                    thisColModel.setHidden(f.id,true)
                 })
                 break;
                case 'edit': 
                Ext.each(majCols,function(f){
                    thisColModel.setHidden(f.id,true)
                 })

                 Ext.each(editCols,function(f){
                    thisColModel.setHidden(f.id,false)
                 })
                 break;
                 case 'all' : 
                 Ext.each(hiddenCols,function(f){
                    thisColModel.setHidden(f.id,false)
                 })
                break;
                }
          }

I have 26 cols in the grid. first I show from 0 to 17 (editCols), second from 18 to 26 (majCols) and last show all

A: 

I d'say it does not depend on the number of columns, but on the number of rows in the grid.

Plus, column hiding/showing has always been slow in Firefox; acceptable for 1 column, but could be slow as hell for 26 columns and lot of rows !

Do you have firebug enabled ? If yes, you could try profiling, by putting console.profile("show/hide cols"); before what you want to profile, and console.profileEnd(); after.

But firebug is itself slowing down Firefox + ExtJS.

Drasill
the grid has a paginBar so the number of rows is 20 per page
cranberies