1
我可以使用瀏覽器寬度自動調整大小的方式來設置JqGrid寬度。JqGrid寬度調整大小調整瀏覽器大小的問題
已嘗試使用此功能。
autowidth:true,
.....
$(window).bind('resize', function() {
$("#table").setGridWidth($("#table").width());
}).trigger('resize');
調整大小的心不是工作正常,當我調整我希望網格相應地調整到瀏覽器的寬度的瀏覽器。
UPDATE:
$(function() {
$grid = $("#table");
$grid.jqGrid({
url: '../../Services/OrderService.asmx/getGlbOrders',
datatype: 'json',
mtype: 'POST',
ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
serializeGridData: function (postData) {
if (postData.searchField === undefined) postData.searchField = null;
if (postData.searchString === undefined) postData.searchString = null;
if (postData.searchOper === undefined) postData.searchOper = null;
//if (postData.filters === undefined) postData.filters = null;
return JSON.stringify(postData);
},
jsonReader: {
root: "d.rows",
page: "d.page",
total: "d.total",
records: "d.records",
id: "d.names"
},
colModel: [
{ name: 'select', label: 'select', width: 50,
formatter: function radio(cellValue, option) {
return '<input type="radio" name="radio_' + option.gid + '" value=' + cellValue + ' />';
}
},
{ name: 'code', label: 'Order ID' },
{ name: 'qty', label: 'Quantity' },
{ name: 'qtyr', label: 'Remaining Qty'},
{ name: 'uts', label: 'Units' },
{ name: 'status', label: 'Status' },
],
rowNum: 10,
rowList: [10, 20, 300],
sortname: 'name',
sortorder: "asc",
pager: "#pager",
viewrecords: true,
gridview: true,
rownumbers: true,
height: 250,
autowidth: true,
caption: 'Global Order List'
}).jqGrid('navGrid', '#pager', { edit: false, add: false, del: false, search: false });
})
$(window).bind('resize', function() {
$("#table").setGridWidth($("#table").width());
}).trigger('resize');
我假設這不適合你。你看到了什麼行爲和/或錯誤? – 2012-01-12 11:53:53
@David:Yesitisnt按預期工作,當我調整瀏覽器的大小時,我希望網格根據瀏覽器寬度調整大小。 – 2012-01-12 11:59:08
它似乎從[問題](http://stackoverflow.com/q/875225/315935)重複。 – Oleg 2012-01-12 12:35:55