简体   繁体   English

如何在 Chrome 中设置文本换行 class

[英]How to set text-wrap class in Chrome

I want use below code to enable line break for the cell.我想使用下面的代码为单元格启用换行符。

Grid6Obj.getRowTemplate().setClass("text", "wrap");

But when I opened the page in chrome and it didn't work.但是当我用chrome打开页面时,它不起作用。 I debug the page and the html is like below.我调试页面,html 如下所示。

<span id="aw36-row-0" class="aw-templates-list aw-text-wrap aw-grid-row aw-row-0 aw-rows-normal aw-alternate-even "><span id="aw36-row-0-start" class="aw-row-start " style="width:0px;"></span><span id="aw36-cell-0-0" class="aw-item-template aw-templates-cell aw-grid-cell aw-column-0 aw-cells-normal " style="border-right:1px  solid #ccc;border-bottom:1px  solid #ccc;" title="">123 456 678</span><span id="aw36-cell-1-0" class="aw-item-template aw-templates-cell aw-grid-cell aw-column-1 aw-cells-normal " style="border-right:1px  solid #ccc;border-bottom:1px  solid #ccc;" title="">12</span><span id="aw36-row-0-end" class="aw-item-template aw-grid-cell aw-column-space "><span id="aw36-row-0-end-box" class="aw-item-box "></span></span></span>

It set the class but the value "123 456 678" is still in one line.它设置了 class 但值“123 456 678”仍在一行中。 Is this because Chrome didn't suppose this class?Then what's the correct way to archieve it?这是因为 Chrome 没有假设这个 class 吗?那么归档它的正确方法是什么? Thx.谢谢。

I did some research for you, there are 3 easy options.我为您做了一些研究,有 3 个简单的选项。 wrap your data in PRE tags将数据包装在 PRE 标签中

<PRE>
123 
456 
678
</PRE>

or in your aw.css file you could change the css on line 17或在您的 aw.css 文件中,您可以在第 17 行更改 css

.aw-text-normal .aw-templates-cell, .aw-text-normal .aw-templates-text, .aw-text-normal .aw-templates-link, .aw-text-normal .aw-item-box {
    white-space:nowrap;
}

Which is set to nowrap, changing this to pre will allow you to hard break your lines.将其设置为 nowrap,将其更改为pre将允许您硬断线。 Though this solution will change all cells to type PRE尽管此解决方案会将所有单元格更改为 PRE

.aw-item-box {
    white-space:pre
}

Alternatively you could mutate your data to this:或者,您可以将您的数据更改为:

"Line1 \r\n Line 2"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM