JQGrid中的列Wordwrap

有人知道如何在JQGrid中包装列名。 请在下面找到我的JSON代码

colModel:[{name:’RequestID’,index:’CreditRequest.CreditRequestID’,width:100,align:’left’},…..

参考上面的代码,如果内容的大小超过我希望它被包装。 任何想法或评论

只需在您自己的css文件中引用它。

.ui-jqgrid tr.jqgrow td { height: 50px; white-space: normal; } 

只要你的css文件列在jqGrid.css文件之后的标题中,它就会覆盖它。

对于它的价值,这里是标题行:

 .ui-jqgrid .ui-jqgrid-htable th div, .ui-jqgrid-sortable { height:auto; overflow:hidden; white-space:normal !important; } 

您需要查看应用于jqGrid列标题的特定类。 在我的情况下,我有以下内容: ui-th-div-ie ui-jqgrid-sortable

再往前看,我发现有两个CSS问题:

  1. 白色空间:正常
  2. 身高:16px

这两个CSS属性都在ui.jqgrid.css中定义。 意识到我对这个网格有一个特定的要求,我不想影响其他实现,我提出了以下解决方案:

 $(".ui-jqgrid-sortable").css('white-space', 'normal'); $(".ui-jqgrid-sortable").css('height', 'auto'); 

以下是在单元格中启用自动换行的几个步骤。

打开ui.jqgrid.css搜索.ui-jqgrid tr.jqgrow td将“white-space:pre;”更改为“white-space:normal;”

对于包裹在单元格中:

 .ui-jqgrid tr.jqgrow td { white-space: normal !important; height:auto; vertical-align:text-top; padding-top:2px; } 

对于列标题

 .ui-jqgrid .ui-jqgrid-htable th div { height:auto; overflow:hidden; padding-right:4px; padding-top:2px; position:relative; vertical-align:text-top; white-space:normal !important; } 

您可以将th标签的空白css属性设置为normal。 使用应该是的JQuery:

  $('.ui-jqgrid .ui-jqgrid-htable th div').css('white-space', 'normal'); 

使用这个CSS

  .ui-jqgrid tr.jqgrow td { word-wrap: break-word; /* IE 5.5+ and CSS3 */ white-space: pre-wrap; /* CSS3 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ overflow: hidden; height: auto; vertical-align: middle; padding-top: 3px; padding-bottom: 3px } 

你不能只是放一个
,虽然这可以包裹线 – 它不会正确调整高度

这适用于jqGrid 4.4.4

 .ui-jqgrid .ui-jqgrid-htable th div { white-space:normal; height:auto !important; } 

确保换行的最简单方法是在列名中放置一个
标记,您需要换行符。 例如, ClientPrimaryName可以写为Client
PrimaryName
,因此它实际呈现为:

客户
PrimaryName