【问题标题】:JqGrid GridView issueJqG​​rid GridView 问题
【发布时间】: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: falsestype: 'text'sortable: truetitle: 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


【解决方案1】:

首先你应该小心使用字母的大小写。 gridview: truegridView: true 不同。同样,您应该使用datatype: 'local' 而不是datatype: 'Local'loadui: 'disable' 而不是loadui: 'Disable'。如果你能正确写出loadui 的值,你可以删除你使用的beforeRequest

要解决您的主要问题,您应该使用height: 'auto'(或height: '100%')或添加其他选项scrollOffset: 0

【讨论】:

  • @Olegthanks 解决了区分大小写的问题。我正在使用虚拟滚动,当我将高度设置为自动时,滚动条消失,它显示网格高度为 500,我看不到其他记录。你怎么看?
  • @AlaaOsta:是的,我现在看到了。您在哪里看到“空白空间”。你能发布屏幕短片来显示你遇到的问题吗?我发现 jqGrid 中虚拟滚动的当前实现不太好。无论如何,scroll:1 的用法都比scroll:true 好。您通常和最多有多少行数据?真的需要虚拟滚动吗?我没有看到任何代码如何填充网格。您通常应该使用data 参数。如果您应该使用data 参数和gridview:true,那么使用数据创建网格将非常快。
  • @Oleg我已经上传了它的快照并编辑了脚本代码以准确显示我是如何做到的。抱歉,我不是说我看不到其余的记录,但它在末尾添加了那个空间
  • @AlaaOsta:从图片中可以看出,您在列和图片中使用了换行符。您如何想象 jqGrid 可以计算具有这种高度的行的总高度?您是否尝试过使用网格没有虚拟滚动?结果如何?这可能是我个人在 jqGrid 中不使用的唯一功能。
  • @Olegg:我的朋友没有换行符,你在说什么?如果您在图像中注意到我故意包含 Html 以查看此 div
    由于高度太大而导致问题
猜你喜欢
  • 2013-07-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-07
  • 2019-04-29
相关资源
最近更新 更多