EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on November 20, 2016, 02:11:10 AM



Title: Programatically resize a panel in layout [solved]
Post by: devnull on November 20, 2016, 02:11:10 AM
I need to save the resized height of a panel to local storage / cooke and then when the user opens the page again set the panel to the previous height.

I do not need help saving and getting cookies, but how can I capture the user resizing a panel which is inside a layout ??

Code:
<layout id="sqlpan">
  <region=north>
  <region=center>

$(document).ready(function() {

  setTimeout(function(){
    $('#sqlpan').layout('panel', 'north').panel({
      onResize: function(h,w) {
        [save h to cookie]
      }
    }).resize({height:[get h from cookie]})
  })

})

Update - it appears that you have to wrap it in a timeout to push to the bottom of the stack as the layout is not ready when the document ready() fires.

But how can I programatically resize the HEIGHT of the north panel ??





Title: Re: Programatically resize a panel in layout
Post by: jarry on November 20, 2016, 07:06:57 AM
Please refer to the code below:
Code:
$(function(){
var height = ...; // get height from cookie
var p = $('#layout').layout('panel','north');
if (height){
p.panel('resize', {height:height});
$('#layout').layout('resize');
}
p.panel('options').onResize = function(width,height){
// save the height to cookie
}
})


Title: Re: Programatically resize a panel in layout
Post by: devnull on November 21, 2016, 06:49:15 AM
Thanks so much