Results 1 to 5 of 5

Thread: How to hide body of gridpanel?

  1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    10
    Answers
    1
    Vote Rating
    0
      0  

    Default How to hide body of gridpanel?

    My grid have some docked toolbars and i want to hide only grid body. I tried to hide like this:



    Code:
    mygrid.body.hide();
    rows disappeared but container height not changed. So instead of grid rows I got empty space..So how collapse and expand gridpanel body?



    Same question here if you want some points

    http://stackoverflow.com/q/10137810/486349

  2. #2
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    119
      0  

    Default

    Try this
    Code:
    grid.setHeight(grid.getHeight() - grid.getView().getHeight());

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    10
    Answers
    1
    Vote Rating
    0
      0  

    Default

    I have tried this it works when I need hide but when I try to show it body loses height so I cannot restore it.

    Code:
    console.log(me.getView().getHeight(),'before');
    me.setHeight(me.getHeight() - me.getView().getHeight());
    me.setHeight(me.getHeight() + me.getView().getHeight());
    console.log(me.getView().getHeight(),'after');
    and result was:
    Code:
     161 before
    
     104 after
    Maybe I should save height somewhere where would best place? there is not one grid those grids created dynamically

  4. #4
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    119
      0  

    Default

    You should save the original grid height if you want to expand it again. Ex:
    Code:
    function collapse(grid){
       if(!grid.originalHeight) grid.originalHeight = grid.getHeight();
       grid.setHeight(grid.getHeight() - grid.getView().getHeight);
    }
    
    function expand(grid){
        if(grid.originalHeight) grid.setHeight(grid.originalHeight);
    }

  5. #5
    Sencha User
    Join Date
    Mar 2012
    Posts
    10
    Answers
    1
    Vote Rating
    0
      0  

    Default

    Almost work just why it disappears after collapse, expand, collapse.

    after some debug maybe I got why. that's because grid.body becomes to tall..

    Code:
    function collapse(grid){
       console.log(grid.getView().getHeight(), grid.getHeight(),'before collapse');
       if(!grid.originalHeight) grid.originalHeight = grid.getHeight();
       grid.setHeight(grid.getHeight() - grid.getView().getHeight());
       console.log(grid.getView().getHeight(), grid.getHeight(),'after collapse');
    
    
    }
    
    
    function expand(grid) {
        console.log(grid.getView().getHeight(), grid.getHeight(),'before expand');
        if(grid.originalHeight) grid.setHeight(grid.originalHeight);
        console.log(grid.getView().getHeight(), grid.getHeight(),'after expand');
    }
    debug:

    Code:
    161 215 before collapse
    52 54 after collapse
    52 54 before expand
    213 215 after expand
    213 215 before collapse
    213 2 after collapse

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •