1

我在单击按钮时重新加载 JQGrid,但是在每次单击时,它的宽度都会增加并放置水平滚动条。即使重新加载,如何将宽度固定为浏览器宽度的 100%。这是我的代码

    jQuery("#enhDg").jqGrid({
    url:"/ItLabourEffort/effort/grid/enhView",
    datatype: "json",
    colNames:['Customer/Capibility Name','Completed-FYTD','In Progress','In Queue','Customer'],
    colModel:[
        {name:'capabilityName',index:'capabilityName' ,width:'500',summaryType:'count', summaryTpl : 'Total Count:  {0}', align: 'center'},
        {name:'completedFYTD',index:'completedFYTD', align:'center', sorttype:'number',summaryType:'sum' ,width:'300'},
        {name:'inProgress',index:'inProgress', align:'center',sorttype:'number',summaryType:'sum',width:'300'},
        {name:'queue',index:'queue', align:'center',width:'250',summaryType:'sum'},
        {name:'customerName',index:'customerName' ,width:'550',summaryType:'count'}

    ],
    rowNum: 10,
    rowList:[10,20,30],
    height:$("#container").height(),
    sortname: 'invdate',
    viewrecords: true,
    width: '100%',
    sortorder: "desc",
    caption:"Enhancement Forecast View",
    grouping: true,
    groupingView : {
        groupField : ['customerName'],
        groupColumnShow : [true],
        groupText : ['<b>{0}</b>'],
        groupCollapse : false,
        loadonce:true,
        groupOrder: ['asc'],
        groupSummary : [true],
        showSummaryOnHide: true,
        groupDataSorted : true
    },
    footerrow: true,
    userDataOnFooter: true,

});
jQuery("#enhDg").jqGrid('navGrid','#enhDg',{add:false,edit:false,del:false});
jQuery("#enhDg").jqGrid('hideCol','customerName');
$('#timeSelectorRadio input[type=radio]').change(function() {
    jQuery("#enhDg").jqGrid().setGridParam(
            {
                datatype:'json', 
                url : "/ItLabourEffort/effort/grid/enhView2"
            }
        ).trigger("reloadGrid");
    jQuery("#enhDg").jqGrid('hideCol','customerName');

    });
4

1 回答 1

0

将宽度:'100%',更改为宽度:自动,然后试试这个

$(window).bind('resize', function() {
    $("#enhDg").setGridWidth($('#grid_container').width() - 30, true);
}).trigger('resize');

你的 html 可能看起来像

<div id="grid_container" style="width: 100%;">
<table id="enhDg">
    <tr>
        <td />
    </tr>
</table>
<div id="pager"></div>
</div>

让我知道这是否有帮助..

于 2013-09-17T15:27:51.337 回答