JQGrid 中的列自动换行
任何人都知道如何在 JQGrid 中包装列名。请在 colModel 下面找到我的 JSON 代码
:[ { name: 'RequestID', index: 'CreditRequest.CreditRequestID', width:100,align: 'left' },.....
参考上面的代码如果内容的大小超过了我希望它被换行。任何想法或评论
Anybody knows on how to wrap column names in JQGrid. Please find my JSON code below
colModel: [
{ name: 'RequestID', index: 'CreditRequest.CreditRequestID', width:100, align: 'left' },.....
With reference to the above code if the size of the content exceeds I want it to be wrapped. Any thoughts or comments
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
只需在您自己的 css 文件中引用它即可。
只要您的 css 文件列在 jqGrid.css 文件后面的标头中,它就会覆盖它。
Just reference it in your own css file.
As long as your css file is listed in the header after the jqGrid.css file then it will override it.
对于它的价值,这里是标题行:
For what it's worth, here it is for the header row:
您需要查看应用于 jqGrid 列标题的特定类。就我而言,我有以下内容:
ui-th-div-ie ui-jqgrid-sortable
再进一步看,我发现存在两个 CSS 问题:
这两个CSS 属性在 ui.jqgrid.css 中定义。意识到我对此网格有一个特定的要求,我不想影响其他实现,因此我提出了以下解决方案:
You need to take a look at the specific classes applied to your jqGrid th column headers. In my case I had the following:
ui-th-div-ie ui-jqgrid-sortable
Looking a little further I found that there were two CSS issues:
Both these CSS attributes where defined in ui.jqgrid.css. Realising that I had a specific requirement for this grid that I didnt want to have affecting other implementations I came up with the following solution:
以下是在单元格中启用自动换行的几个步骤。
打开 ui.jqgrid.css
搜索 .ui-jqgrid tr.jqgrow td
更改“空白:pre;”到“空白:正常;”
对于单元格换行:
以及列标题
Here is a few steps to enable word wrapping in the cells.
Open up ui.jqgrid.css
Search for .ui-jqgrid tr.jqgrow td
Change “white-space: pre;” to “white-space: normal;”
For wrap in cell:
And for column headers
您可以将 th 标签的空白 css 属性设置为正常。使用 JQuery 应该是:
You can set a white-space css property of th tag to normal. Using JQuery that should be:
使用这个CSS
Use this css
你不能只放一个
,虽然它可以包裹线 - 它不能正确调整高度you cant just put a
<BR/>
, while that works on wrapping the line - it doesnt adjust the height properly这适用于 jqGrid 4.4.4
This worked with jqGrid 4.4.4
确保换行符的最简单方法是在列名称中需要换行符的位置放置一个
标记。例如,ClientPrimaryName
可以写为Client
,这样它实际上呈现为:/>PrimaryName
Client
PrimaryName
Well the simplest way to ensure a line break is to put a
<BR/>
tag in the column name where ever you need a line break. For instanceClientPrimaryName
can be written asClient<BR/>PrimaryName
, so that it actually renders as:Client
PrimaryName