AdminLTE, get width of an element using the "pushMenu" plugin when using "collapsed / expanded"

0

As you can see I am using a template for my web development (AdminLTE), in this case the AdminLTE, and I am using the jqGrid to work my records.

What I want is to obtain the current width of an element after having made the expand / collapse event.

<script>
jQuery(function($) {

var grid_selector = "#grid-table";
var pager_selector = "#grid-pager";

//Obtener un Elemento
var parent_column = $(grid_selector).closest('[class*="col-"]');

//Redimensiono inicialmente
$(window).on('resize.jqGrid', function () {
    $(grid_selector).jqGrid( 'setGridWidth', parent_column.width() );
}) 

$(document).on('collapsed.pushMenu expanded.pushMenu', function(ev){
            var event_name = ev.type;
            if( event_name === 'collapsed' || event_name === 'expanded' ) {
               
                setTimeout(function() {
                //Aqui es donde no puedo obtener el ancho del elemento, para poder redimensionar mi jqGrid
                    var parent_column = $(grid_selector).closest('[class*="col-"]');
                    $(grid_selector).jqGrid( 'setGridWidth', parent_column.width() );
                }, 20);
            }
        });

})

</script>

As you will see after detecting the event collapsed / expanded I can not get the current width of the element saved in the variable "parent_column".

Greetings!

    
asked by WUNDERWAFFEN077 20.04.2018 в 06:54
source

1 answer

0

I answer, I had to add 500 to the timeout function, it seems that it takes a while to resize. It's weird since I use the value 20 on the other template.

    
answered by 20.04.2018 в 07:16