I'm having a problem with jqGrid. I have a table with many columns. When I change the window or If open the web app in a mobile device, It should show only 4 or 5 columns in the grid table instead of many columns or else It should allow scrolling within the grid. So how to reduce the number of columns in the JQGrid on the window resize event?.
I have tried like following and the resize event is working fine but look&feel is not good due to more columns in the grid and no scroll bar.
My Html,
<table id="list2"></table>
My jqGrid code,
$("#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', width: 55 },
{ name: 'id', index: 'id', width: 55, hidden: true },
{ name: 'Project_Name', index: 'Project_Name', width: 140 },
{ name: 'Project_Name2', index: 'Project_Name2', width: 140 },
{ name: 'Project_Name3', index: 'Project_Name3', width: 140 },
{ name: 'Project_Number', index: 'Project_Number', width: 140 },
{ name: 'Project_Manager', index: 'Project_Manager', width: 140 },
{ name: 'Business_Unit', index: 'Business_Unit', width: 140 },
{ name: 'Project_Admin_Name', index: 'Project_Admin_Name', width: 140, align: "right" },
{ name: 'Remarks', index: 'Remarks', width: 180, align: "right" },
{ name: 'Is_Active', index: 'Is_Active', width: 100, align: "right" },
{ name: 'Created_Date', index: 'Created_Date', width: 150, sortable: false },
{ name: 'Modified_Date', index: 'Modified_Date', width: 150, sortable: false }
],
rowNum: 10,
rowList: [10, 20, 30,50,100,500,1000],
//pager: '#pager2',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
loadonce: true,
ignoreCase: true,
viewrecords: true,
pagepos: 'left',
forceFit: true,
shrinkToFit: false, // to enable the scroll bar in the responsive mode
height: 500,
width:1600,
altRows:true,
altclass:'myAltRowClass'
});
My Script,
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