how to remove/disable column resize in jqGrid

jqGrid columns are set to resizable by default. Bit if you want to fix there size and want to disable or remove the resizable property then you can easily specify it in colmodel API. The colModel property defines the individual grid columns as an array of properties. This is the most important part of the jqGrid, and you can set the resizable variable of this array to false in order to disable the column resize.

jqGrid configuration option to remove column resize

var jqGridObj = $('#tableIdForGrid');

jqGridObj.jqGrid({  
...,
"colModel" : [
{
"name":"description",
"index":"description",
"align":"left",
"sorttype":"text",
"width" : 50,
"resizable": false,
}
],
...,
});



Other Imp variables of comModel API > click here

how to set width of column of jqGrid

Working on jqGrid, and want to change the width of columns? You are landed at a right place take a look at following discussion to get it done quickly. jqGrid is very easy to configure and it has lots of functions and variables to customize it as per our needs.

use this in jqGrid configuration code

var jqGridObj = $('#tableIdForGrid');

jqGridObj.jqGrid({  
...,
"colModel" : [
{
"name":"description",
"index":"description",
"align":"left",
"sorttype":"text",
"width" : 50, 
}
],
...,
});

Explanation
You can easily set the width of every column of jqGrid by the configuration variable width in colModel property of jqGrid. Above sample code is self explanatory.

how to remove pagination from jqGrid

If you set rowNum = -1 in jqGrid configuration options then it will display all records instead of dividing rows in no of pages. But this configuration keeps the pagination HTML as it is there in bottom or top toolbar. To remove it completely from jqGrid then we have to delete that HTML with help of jQuery and dom operations. Take a look at following code to remove the pagination from jqGrid completely.

jqGrid configuration Code

var jqGridObj = $('#'+tblId);

jqGridObj.jqGrid({  
            ....,
            ....,
            rowNum:-1,   // this loads all the records.
            ...
            ...
            other config options,
            gridComplete: function(){
              // this line removes the HTML of pagination 
              $('#pager'+jqGridObj[0].id+'_center').hide();
            },
            ..
         });

how to show all rows n remove paging in jqGrid

If you want to display all the records / rows in the jqGrid and don't want to display the pagination then, you can do with the help of following code snippet. jqGrid has a configuration option rowNum, you have to set it to -1 to display all the rows in loaded grid.

jqGrid configuration Code

var jqGridObj = $('#'+tblId);

jqGridObj.jqGrid({  
            ....,
            ....,
            rowNum:-1,
            ...
            ...
            other config options,
            ..
         });


Alternate Method
Another Method to remove pager completely from jqGrid

how to count number of rows in jqGrid - reccount

jqGrid is really a very nice and easiest tool to integrate datagrid. It also has lots of functions so that we can customize it as per our needs and as per my knowledge we can do almost any thing with it. If you want to count the number of rows in a jqGrid then you can simply use the following code.
JS Code

var jqGridObj = $('#gridTableId');
alert(jqGridObj.getGridParam("reccount"));

For old version of jqGrid
jqGridObj .jqGrid('getGridParam', 'records');

Explanation
getGridParam added in new version of jqGrid, we can use it to read any property of the loaded grid with the help of object. In our example jqGridObj is object. We can pass the variable which we want to retrive from loaded grid. In above example we need to retrieve number of rows in jqGrid, so we have specified "reccount" as a parameter to the function.

SHARE