我使用jqgrid v4.4.5和jquery v1.9.1。 当我调整 jqgrid 的大小并且出现水平滚动条时,它可以在 IE 和 Firefox 上运行。但在 Chrome 中不起作用,列被截断并且宽度计算错误。
我该如何解决这个问题?
<script>
$(function () {
$("#UsersGrid").jqGrid({
direction:"rtl",
url: 'jqGridHandler.ashx',
datatype: 'json',
height: 250,
colNames: ['UserID', 'UserName', 'FirstName', 'MiddleName', 'LastName', 'EmailID'],
colModel: [
{ name: 'UserID', index: 'UserID', width: 100, sortable: true },
{ name: 'UserName', width: 100, sortable: true },
{ name: 'FirstName', width: 100, sortable: true },
{ name: 'MiddleName', width: 100, sortable: true },
{ name: 'LastName', width: 100, sortable: true },
{ name: 'EmailID', width: 150, sortable: true }
],
rowNum: 10,
rowList: [10, 20, 30],
pager: '#UsersGridPager',
sortname: 'UserID',
viewrecords: true,
sortorder: 'asc',
caption: 'JSON Example'
});
$("#UsersGrid").jqGrid('navGrid', '#UsersGridPager', { edit: false, add: false, del: false });
});
</script>
最佳答案
如 documentation 中所示shrinkToFit
属性如果设置,则定义如何重新计算网格列的宽度,同时考虑网格的宽度。如果该值为 true,并且还设置了列的宽度,则每列将按其宽度的比例缩放。
When set to true, the grid width is recalculated automatically to the width of the parent element. This is done only initially when the grid is created. In order to resize the grid when the parent element changes width you should apply custom code and use a setGridWidth method for this purpose.
因此,您只需将属性添加到 jqGrid 即可:
shrinkToFit:true,
关于jquery - jqgrid v4.4.5 rtl水平,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16034005/