Render a newline in my data inside a jqGrid cell

2019-09-08 03:14发布

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条回答
老娘就宠你
2楼-- · 2019-09-08 03:49

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/>

查看更多
登录 后发表回答