Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqGrid horizontal scrollbar

I developed AJAX interface with jQuery and jqGrid.

How I can remove horizontal scrollbar from my jqGrid table?

http://dskarataev.ru/jqgrid.png

If I set autowidth: true, then I get width of table = sum width of columns, but I need width of table = width of parent element with id returned by function getSelectedTabHref()

so I make function:

$(window).bind('resize', function() {
  $('#tasks').setGridWidth($(getSelectedTabHref()).width());
  $('#tasks').setGridHeight($(window).height()-190);
}).trigger('resize');

and here is how I create jqGrid table:

$('#tasks').jqGrid({
  datatype: 'local',
  colNames:[labels['tasksNum'],labels['tasksAdded']+"/"+labels['tasksAccepted'],labels['tasksOperator'],labels['tasksClient'],labels['tasksManager'],labels['tasksDesc']],
  colModel :[
    {name:'taskId', index:'taskId', width:1, align:'right'},
    {name:'taskAdded', index:'taskAdded', width:3},
    {name:'taskOperator', index:'taskOperator', width:4},
    {name:'taskClient', index:'taskClient', width:7},
    {name:'taskManager', index:'taskManager', width:4},
    {name:'taskDesc', index:'taskDesc', width:8}]
});

like image 887
dskarataev Avatar asked Jun 22 '10 07:06

dskarataev


3 Answers

i adjusted ui.grid.css because i did not need a horizontal scrollbar at all. i did this:

.ui-jqgrid .ui-jqgrid-bdiv {   position: relative;    margin: 0em;    padding:0;    /*overflow: auto;*/    overflow-x:hidden;    overflow-y:auto;    text-align:left; } 

the commented was how it was, i just used overflow-x to hide the horizontal scrollbar and now all is fine with me.

like image 129
Herman van der Blom Avatar answered Sep 20 '22 01:09

Herman van der Blom


There are some situations where jqGrid calculate the grid width incorrect. You can try to increase cellLayout parameter (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options). This may be needed if you change some CSS from jqGrid.

In some other situations you can correct the width with respect of the function fixGridWidth or fixGridSize which I have described in Correctly calling setGridWidth on a jqGrid inside a jQueryUI Dialog. Don't forget, that you should use it inside of loadComplete.

like image 29
Oleg Avatar answered Sep 20 '22 01:09

Oleg


Set an explicit width on the grid and use

autowidth: false,
shrinkToFit: true
like image 39
arviman Avatar answered Sep 19 '22 01:09

arviman