JQGrid标头和列未对齐 [英] JQGrid header and column not aligned

查看:75
本文介绍了JQGrid标头和列未对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jqgrid,在特定的流程中,标题和列都未对齐.我在stackoverflow上发现了类似的问题,但是解决方案对我而言不起作用.作为记录,我使用了由Oleg在

I am using jqgrid, and in a particular flow, the headers and columns are getting misaligned. I have found similar questions on stackoverflow, but the solutions have not worked for me. For the record, I have set the widths of the columns dynamically based on the content of their columns, using a block of code that was provided by Oleg in this question. and then i am using setColWidth function of the jqGrid to set the grid width. I was debugging this issue that I am facing, and I had to look into jqgrid.setcolwidth.js where there is a function called dragEnd(). When i further looked into this function, I found that the first misalignment is happening in the following statement

!0===d.forceFit?(e=
this.headers[c+d.nv].newWidth||this.headers[c+d.nv].width,this.headers[c+d.nv].width=e,this.headers[c+d.nv].el.style.width=e+"px",this.cols[c+d.nv].style.width=e+"px",0<this.footers.length&&(this.footers[c+d.nv].style.width=e+"px"),d.colModel[c+d.nv].width=e):(d.tblwidth=this.newWidth||d.tblwidth,b("table:first",this.bDiv).css("width",d.tblwidth+"px"),b("table:first",this.hDiv).css("width",d.tblwidth+"px"),this.hDiv.scrollLeft=this.bDiv.scrollLeft,d.footerrow&&(b("table:first",this.sDiv).css("width",
d.tblwidth+"px"),this.sDiv.scrollLeft=this.bDiv.scrollLeft));

此代码段位于jquery.jqgrid.min.js中,并且所有列的对齐方式均不会失真,但第11列的对齐方式不会失真.从这两个函数调用返回到我的js文件后,该列的标题宽度与该列的td宽度(.jqgfirstrow和.jqgrow)不同

This snippet is there in jquery.jqgrid.min.js and the alignment does not get distorted for all the columns, but for the 11th column. After it returns from these 2 function calls to my js file, the width of the header of that column is different from the width of the td's of the column(both .jqgfirstrow and .jqgrow)

我不确定该怎么做,并且试图找出问题的根本原因无所适从.如果你们中的任何一个可以阐明为什么它可能如此运行,或者jqgrid如何精确设置其列和标题的宽度,那将是非常棒的.

I am not sure what to make out of this and am at a loss trying to find the root cause of the problem. It will be really great if any of you can shed some light on why it might be behaving like this, or maybe how does jqgrid exactly set the widths of its columns and headers.

注意:那里的forceFit值是false.

Note: the value of forceFit is false there.

谢谢.

推荐答案

我想您使用的是 jqGrid的某些旧版本.我建议您升级到免费jqGrid 的最新版本(版本为4.12.1,但我计划在未来几天发布4.13.0).免费jqGrid是jqGrid的分支,我从2014年底开始开发.

I suppose that you use some old version of jqGrid. I suggest you to upgrade to the latest version of free jqGrid (it's version 4.12.1, but I plan to publish 4.13.0 in the next days). Free jqGrid is the fork of jqGrid, which I develop since the end of 2014.

我在免费jqGrid中包含了许多错误修复程序并实现了新功能.方法setColWidth包含在主代码中.此外,还有许多新功能,例如

I included many bug fixes and implemented new features in free jqGrid. the method setColWidth is included in the main code. Moreover there are many new features, like auto-adjustment of column width based on the column content, labelClasses, labelAlign (see the demo) and many many other features described in the readme to every published version and someone in the wiki.

我建议您使用免费的jqGrid.您可以从CDN加载它,例如通过

I suggest you to use free jqGrid. You can load it from CDN, for example by usage URLs described here. I hope that the problem will be disappear automatically.

这篇关于JQGrid标头和列未对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆