【发布时间】:2012-05-01 14:44:09
【问题描述】:
如果我将 gridView 属性设置为 true,则表格高度设置不正确,它在最后一条记录下方显示空白空间。 我认为它正在完成最后一页的 rowNum。是错误还是我缺少要设置的属性? 这只发生在 FireFox 中
$('#jqgInventory').jqGrid({
autowidth: true,
caption: 'Inventory',
datatype:'local',
forceFit: true,
gridview: true,
height: 500,
hidegrid: false,
ignoreCase: true,
loadonce: true,
loadui: 'disable',
rowNum:25,
scroll:true,
shrinkToFit: true,
viewrecords: true,
beforeRequest: function() {$('#gridScript').block();},
beforeSelectRow: function(rowid, e) {return false;},
gridComplete: function() {$('#lblVehicleCount').html($('#jqgInventory').getGridParam('records'));$('#gridScript').unblock();Inventory.modifyGridCellClick();},
colModel: [
{
align: 'Center',
name:'Select',
label: 'SEL',
title: true,
width:20,
index:'Select'
},{
align: 'Left',
name:'Photo',
hidden: false,
label: 'PHOTO',
stype:'text',
sortable: false,
sorttype:'text',
title: true,
width:100,
index:'Photo'
},{
align: 'Left',
name:'Information',
hidden: false,
label: 'INFO',
stype:'text',
sortable: false,
sorttype:'text',
title: true,
width:100,
index:'Information'
},{
align: 'Right',
name:'Price',
hidden: false,
label: 'PRICE',
stype:'text',
sortable: true,
sorttype:function(cellValue){return CustomGridSortByIntegerAsString(cellValue);},
title: true,
width:50,
index:'Price'
},{
align: 'Right',
name:'Mileage',
hidden: false,
label: 'MILEAGE',
stype:'text',
sortable: true,
sorttype:function(cellValue){return CustomGridSortByIntegerAsString(cellValue);},
title: true,
width:25,
index:'Mileage'
},{
align: 'Right',
name:'Age',
hidden: false,
label: 'AGE',
stype:'text',
sortable: true,
sorttype:function(cellValue){return CustomGridSortByIntegerAsString(cellValue);},
title: true,
width:50,
index:'Age'
},{
name:'VehicleKey',
hidden: true,
label: 'VEHICLEKEY',
width:50,
index:'VehicleKey'
}
]
,data:data});
【问题讨论】:
-
格式如此糟糕的代码很难阅读。此外,代码包含许多默认属性,如
hidden: false、stype: 'text'、sortable: true、title: true。这些属性是纯粹的垃圾,会增加代码的大小,并且必须滚动代码才能阅读。可以额外减少和简化代码的是column templates。您可以定义变量var myTempl = {align: 'right', sorttype: function (cellValue) { return CustomGridSortByIntegerAsString(cellValue); }, width: 50}并在某些列中使用它。
标签: jquery-ui jqgrid jqgrid-asp.net jqgrid-php jqgrid-formatter