Bil*_*lla 9 html css jquery jqgrid twitter-bootstrap
我开始在许多地方创建应用程序使用jQgrid.现在,客户希望使用Twitter Bootstrap,以便他们可以在iPad中很好地查看该网站.
除了jQGrid插件,我们几乎完成了所有工作.它使用a px width来定义网格的宽度和column width.
jQuery("#list2").jqGrid({
url:'server.php?q=2',
datatype: "json",
colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
colModel:[
{name:'id',index:'id', width:55},
{name:'invdate',index:'invdate', width:90},
{name:'name',index:'name asc, invdate', width:100},
{name:'amount',index:'amount', width:80, align:"right"},
{name:'tax',index:'tax', width:80, align:"right"},
{name:'total',index:'total', width:80,align:"right"},
{name:'note',index:'note', width:150, sortable:false}
],
rowNum:10,
rowList:[10,20,30],
pager: '#pager2',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption:"JSON Example"
});
jQuery("#list2").jqGrid('navGrid','#pager2',{edit:false,add:false,del:false});
Run Code Online (Sandbox Code Playgroud)
我不知道如何用jQGrid处理这个响应问题.或者,我可以用DataTable插件替换jQGrid以获得响应.但是我们在许多地方使用jQgrid并且功能非常好,我们不想破坏现有的功能.
有什么想法/建议使用jQgrid作为响应/流体布局支持?
我发现这个解决方案,它在我的应用程序上工作正常.
把你的表包裹在div中:
<div id="jqGrid_container">
<table id="jqList"></table>
<div id="jqPager"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
并在您的JavaScript代码中:
$(window).bind('resize', function() {
var width = $('#jqGrid_container').width();
$('#jqList').setGridWidth(width);
});
Run Code Online (Sandbox Code Playgroud)
或者如果您不需要调整大小,只需:
$( document ).ready(function() {
var width = $('#jqGrid_container').width();
$('#jqList').setGridWidth(width);
});
Run Code Online (Sandbox Code Playgroud)
我想你还需要输入你的jqgrid选项:autowidth:true,shrinkToFit:true,