Render a newline in my data inside a jqGrid cell

梦想的初衷 提交于 2020-01-06 06:08:25

问题


First off, I'm using version 3.7.1 with a jQuery UI framework theme. I'm trying to figure out how to have a newline or even a <br /> render inside of a jqGrid cell.

An example of what I'm looking to have happen:

________________________________________________________
Item 1     |   some data   |  Applies to OS 1
                              Applies to OS 2
                              Applies to OS 3
                              Applies to OS 4
__________________________________________________________
Item 2     |   some data   |  Applies to OS 1
__________________________________________________________
Item 3     |   some data   |  Applies to OS 4
                              Applies to OS 5
__________________________________________________________

What currently happens when my data has either a <br /> or a \n is:

__________________________________________________________
Item 1     |   some data   |  Applies to OS 1Applies to OS 2Applies to OS 3Applies to OS 4

I would rather not have to use an actual <br /> tag, since I'd rather not have HTML embedded in my data, but am willing to do whatever I have to since I NEED to render this data as a list of values. Thanks for any help.


回答1:


You should use custom formatter (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter) for the column where you need to have <br />. This allow you to defina any HTML fragment for a column. See jqGrid: Editable column that always shows a select as an example.

Probably Wrapping Text lines in JqGrid will be also helpful for you.

P.S. If you will have problems with the usage of custom formatter, post a column definition and a raw data example (JSON data for example) for the column where you want have <br/>



来源:https://stackoverflow.com/questions/3097498/render-a-newline-in-my-data-inside-a-jqgrid-cell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!