четверг, 17 ноября 2011 г.

Resize window , resize grid

Preface

I had a task to resize Ext js grid, after the main window was resized. After investigating this topic , I find how to do it and I want to share it with you.

Implementation

The secret of this task is to use ExtJs class "EventManager". This class is responsible for registering events in ExtJ library. So in order to do it , first of all we need to subscribe to window resize event.
To do it we need to define a delegate to to onWindowResize event
   Ext.EventManager.onWindowResize

Afterwords we can just calculate width and height of grid and to assign it .
See example below


Ext.EventManager.onWindowResize(function () {

    var tmpHeight = Ext.getBody().getViewSize().height - 160;
    var height = Ext.getBody().getViewSize().height - 140;

    grid.setSize(width, height);

});

Summary

So we learned how to change the grid size and height. Please see other useful links:

Комментариев нет:

Отправить комментарий