Resize jqGrid according to number of columns in the grid

前端 未结 1 1320
清酒与你
清酒与你 2021-01-24 09:33

I have jqGrid (free jqGrid) that contains 7 columns. And I applied shrinkToFit: false, property to enable scrolling for the grid columns (to fit to mobile device).

相关标签:
1条回答
  • 2021-01-24 09:41

    You can use setColWidth method (included in free jqGrid) to change the width of the last column dynamically. I don't know which scenario for loading the grid you use. The modification of the demo could be the following: http://jsfiddle.net/OlegKi/andm1299/37/ where

    $(window).bind("resize", function () {
        var p = $grid.jqGrid("getGridParam"),
            cm = p.colModel[p.iColByName.ComboDuration];
    
        $grid.jqGrid("setGridWidth", $grid.closest(".container-fluid").width());
        $grid.jqGrid("setColWidth", "ComboDuration", p.width - p.tblwidth + cm.width);
    }).triggerHandler("resize");
    

    The above code first resize the width of grid based on the width of the outer container and then adjust the width of the last column based on the difference between the width of the main grid table and the total width of the grid.

    0 讨论(0)
提交回复
热议问题