您现在的位置:首页 >> 前端 >> 内容

easyui datagrid动态改变大小教程(代码)

时间:2018/1/26 14:12:05 点击:

  核心提示:easyui Layout中改变大小时对应datagrid大小自适应问题由于center的layout中 datagrid被嵌入了一个p,当左右拖动west的Layout时,在Layout cente...

easyui Layout中改变大小时对应datagrid大小自适应问题

由于center的layout中 datagrid被嵌入了一个p,当左右拖动west的Layout时,在Layout center中的datagrid宽度不变(可能是datagrid外面被嵌套了一个p吧,当没有p时好像是可以动态适应的),导致用户体验问题,通过panel的onResize事件去处理,将动态取得宽度,通过datagrid 的resize方法设置到datagrid中,可现实动态适应宽度和高度

 <p  class="easyui-layout"  data-options="fit:true">
        <p data-options="region:'west',split:true" title="群体" style="width:500px;">
        <table id="grouppushlist" style="padding-top: 0px;"></table>
        </p>
       
        <p id='Content_table' data-options="region:'center',title:'操作展示',iconCls:'icon-ok'">
        <p id="personallist" class="easyui-resizable" style="display:none;width:inherit;height:inherit;"  >
            <table id="pushlist" ></table>
        </p>
        
        </p>
    </p>

以下实现事件监听:

$(document).ready(function(){
$('#Content_table').panel({
  onResize:function(width, height){
   
$('#personallist').width(width);
   
$('#personallist').height(height);
   
$('#pushlist').datagrid('resize',{width:width});
   
}
  });
}

Tags:EA AS SY YU 
作者:网络 来源:qq_3920529