如何在GWT单元格EditTextCell中添加多行文本?
我有一个显示数据的单元格表。我想编辑单元格以在多行中提供信息。
例子: 键1=值1|在下一行中添加另一个键: 键2=值2|
编辑值后,当显示/重绘单元格表时,信息应如上所示在单元格中显示。
I have a celltable displayed with data. I want to edit the cells to give information in multiple lines.
Example:
key1=value1| In next line add anoter key:
key2=value2|
After editing the values, when the celltable is displayed/ redrawn then the info should be displayed as above in the cells.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我已经解决了部分问题。我将 CellTable 与自定义 TextAreaEditCell 一起使用。现在我可以输入多行数据。但是当它进入数据库或单元表显示信息时,信息是顺序形式的。
示例:
当我在 TestAreaCell 中输入这样的数据时:
abcd
在下一行中,输入 efgh,然后
显示的输出为:
abcdefgh
问题:似乎未考虑回车键:
下面是我的 TextAreaEditCell 类。如果需要进行任何更正,请告诉我。
我已经解决了部分问题。我将 CellTable 与自定义 TextAreaEditCell 一起使用。现在我可以输入多行数据。但是当它进入数据库或单元表显示信息时,信息是顺序形式的。
示例:
当我在 TestAreaCell 中输入这样的数据时:
abcd
在下一行中,输入 efgh,然后
显示的输出为:
abcdefgh
问题:似乎未考虑回车键:
下面是我的 TestAreaEditCell 类。如果需要进行任何更正,请告诉我。
I have solved part of the issue. I am using CellTable with customized TextAreaEditCell. Now I am able to enter multiple lines of data. But when it goes to database or when celltable displayed the information, the info is in sequential form.
Example:
when i enter data like this in TestAreaCell:
abcd
In next line, enter efgh then the
Output when displayed is:
abcdefgh
Issue: Seems the enter key is not getting considered:
My TextAreaEditCell class is below. Please let me know if any corrections need to be done.
I have solved part of the issue. I am using CellTable with customized TextAreaEditCell. Now I am able to enter multiple lines of data. But when it goes to database or when celltable displayed the information, the info is in sequential form.
Example:
when i enter data like this in TestAreaCell:
abcd
In next line, enter efgh then the
Output when displayed is:
abcdefgh
Issue: Seems the enter key is not getting considered:
My TestAreaEditCell class is below. Please let me know if any corrections need to be done.
我也做过类似的事情;虽然不完全一样。所以也许这样的东西会起作用。
您需要提供自己的 render() 方法。因此,在下面的 render() 方法中,您可以添加任何您想要的内容。
列选择CheckBoxColumn =
新列(新MyCheckBoxCell()){
I have done a similar thing; although not exactly the same. So maybe SOMETHING like this will work.
You need to provide your own render() method. So in the render() method below, you can add whatever you want.
Column selectCheckBoxColumn =
new Column(new MyCheckBoxCell()) {
您必须将换行符 (\n) 转换为 HTML 换行符 (
)
您可以在将数据保存到后端时执行此操作,也可以在 TextAreaEditCell 的渲染方法中执行此操作 类似这样的东西
:
You have to convert the line-breaks (\n) to HTML line breaks (<BR>)
Either you can do this when you save the data on your backend or you can do it in the render method of your TextAreaEditCell
Something like that:
这是 render 方法的一个工作解决方案,它将在 TextAreaEditCell 中显示多行。基本上,您根据 \n 字符拆分存储的字符串,然后将它们连接起来,附加
标记作为 SafeBuilder 的 HTML 常量。
@覆盖
公共无效渲染(上下文上下文,字符串值,SafeHtmlBuilder sb){
Here is a working solution of the render method which will display multi line in a TextAreaEditCell. Basically you are splitting the stored string based on the \n character and then joining them appending the
tag as a HTML constant for the SafeBuilder.
@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {