jqGrid出现问题。我的桌子上有很多列。当我更改窗口或在移动设备中打开Web应用程序时,它应在网格表中仅显示4或5列,而不是许多列,否则应允许在网格内滚动。那么如何在窗口调整大小事件上减少JQGrid中的列数呢?
我已经尝试过以下操作,但resize事件工作正常,但由于网格中的列数更多,并且没有滚动条,因此外观感觉也不佳。
我的HTML,
<table id="list2"></table>
我的jqGrid代码,
$("#list2").jqGrid({
url: '/Project/GridData',datatype: "json",mtype: 'POST',colNames: ['edit','view','id','Project_Name','Project_Name2','Project_Nam3','Project_Number','Project_Manager','Business_Unit','Project_Admin_Name','Remarks','Is_active','Created_Date','Modified_Date'],colModel: [
{ name: 'edit',index: 'edit',width: 55 },{ name: 'view',index: 'view',{ name: 'id',index: 'id',width: 55,hidden: true },{ name: 'Project_Name',index: 'Project_Name',width: 140 },{ name: 'Project_Name2',index: 'Project_Name2',{ name: 'Project_Name3',index: 'Project_Name3',{ name: 'Project_Number',index: 'Project_Number',{ name: 'Project_Manager',index: 'Project_Manager',{ name: 'Business_Unit',index: 'Business_Unit',{ name: 'Project_Admin_Name',index: 'Project_Admin_Name',width: 140,align: "right" },{ name: 'Remarks',index: 'Remarks',width: 180,{ name: 'Is_active',index: 'Is_active',width: 100,{ name: 'Created_Date',index: 'Created_Date',width: 150,sortable: false },{ name: 'Modified_Date',index: 'Modified_Date',sortable: false }
],rowNum: 10,rowList: [10,20,30,50,100,500,1000],//pager: '#pager2',sortname: 'id',viewrecords: true,sortorder: "desc",loadonce: true,ignoreCase: true,pagepos: 'left',forceFit: true,shrinkToFit: false,// to enable the scroll bar in the responsive mode
height: 500,width:1600,altRows:true,altclass:'myAltRowClass'
});
我的脚本,
var $grid = $("#ProjectSearchGrid"),newWidth = $grid.closest(".ui-jqgrid").parent().width();
$grid.jqGrid("setGridWidth",newWidth,true); // change the grid size based on parent div size
$grid.jqGrid('setColProp','ProjectName',{width:100}); //change the column size for consistent look in the mobile device