jeasyUI DataGrid 根据屏幕宽度自适应, 改变右侧滚动条Size

时间:2023-03-10 05:54:09
jeasyUI DataGrid 根据屏幕宽度自适应, 改变右侧滚动条Size

PC浏览器的Datagrid可以显示多几列,但是在手机浏览器时,只能有选择性的显示前几列.

           $(window).resize(function () {
if (document.body.clientWidth <= 414) {
$('#grid').datagrid('hideColumn', 'id');
$('#grid').datagrid('hideColumn', 'prodCode');
$('#grid').datagrid('hideColumn', 'referee');
$('#grid').datagrid('hideColumn', 'createDate'); }
else { $('#grid').datagrid('showColumn', 'id');
$('#grid').datagrid('showColumn', 'prodCode');
$('#grid').datagrid('showColumn', 'referee');
$('#grid').datagrid('showColumn', 'createDate'); }
});

但是在chrome切换 PC/Mobile时, showColumn 每列的宽度不一样. 还没有设置列宽的方法.

所以就不在(window).resize里写了.

Datagrid的滚动条默认Size是18px,在手机上是很大的空白, 怎样改这个size呢?

 $('#grid').datagrid({
...
scrollbarSize: (document.body.clientWidth <= 414?6:18),
...
});