GWT 同一列中有不同的列类型?
我正在开发一个 GWT 应用程序,到目前为止,我很喜欢 Java 开发人员友好的 UI 框架!
到目前为止,我已经能够使用这些小部件做几乎任何事情,但是这个让我难住了。我有一个单元格表,用作用户输入源。它只是用户输入键值对来调用我的服务的一种方式。用户可以动态添加行和删除行。
现在棘手的部分是我想强制用户输入某些键的值。这些键只有特定的 4-5 个可接受的值,因此对于这些行,我想将 editableTextCell 替换为 SelectionCell。考虑到列单元格类型声明是在将列添加到表中时完成的,不确定如何在表中混合单元格类型。
任何意见表示赞赏!
谢谢
I'm working on a GWT app, and so far I'm loving the Java developer friendly UI framework!
So far I've been able to do pretty much anything with the widgets, but this one has me stumped. I have a cell table, that I use as a user input source. Its just a way for users to enter key-value pairs to call my service. User can dynamically add rows and delete rows.
Now the tricky part is I want to force the user to enter value for some keys. There are only certain 4-5 acceptable values for these keys so for those rows I would like to replace the editableTextCell with a selectionCell. Not sure how I can mix cell types within a table, given that the column cell type declaration is done while adding the column to the table.
Any input is appreciated!
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须创建一个自定义单元格,有时会呈现
。如果您查看 EditableTextCell 和 SelectionCell 的代码,您可以了解如何实现这一目标。它可能非常简单 - 您可以编写其中的一个,然后在您的渲染函数中将数据传递到适当的单元格。
类似...
(未经测试的代码)
You'll have to create a custom Cell that sometimes renders a
<select>
and sometimes renders an<input>
. If you look at the code of EditableTextCell and SelectionCell you can get ideas about how to accomplish that. It may be pretty simple - you could compose one of each, and in yourrender
function just pass the data to the appropriate cell.Something like...
(untested code)
非常有用。这是我对条件渲染的
CheckboxCell
的看法Very useful. Here is my take on a conditionally rendered
CheckboxCell
稍后回答,但无论如何。几天前,也面临着这个任务 - 必须在一列中使用文本或组合框进行单元格编辑。这是我的实现:
自定义 GridInlineEditing 实现如下:
这是相当解决方法,不是优雅的实现,但无论如何,它工作得很好
A little bit later answer, but any way. Few days ago a faced this task also - text or combo boxes has to be used in one column for cell editing. Here are my implementation:
And custom GridInlineEditing implementation is as this:
It is rather workaround, not elegant implementation, but any way, it works fine