简体   繁体   English

GWT celltable如何在edittextcell中创建selectioncell?

[英]GWT celltable How to create selectioncell in edittextcell?

I want to create editable cell with datatype boolean. 我想创建数据类型为布尔值的可编辑单元格。

I don't want to use selectioncell for boolean data type 我不想为布尔数据类型使用selectioncell

My testBooleanColumn column's cell contains string with value true,false.......... 我的testBooleanColumn列的单元格包含值为true,false的字符串..........

when I will click on cell present in testBooleanColumn then that cell should be editable and In that editable cell I want to show selection cell with value(true,false). 当我单击testBooleanColumn中存在的单元格时,该单元格应该是可编辑的,并且在该可编辑单元格中,我要显示具有value(true,false)的选择单元格。 when user changes value from selectioncell either true or false that value set to editable cell in testBooleanColumn 当用户从selectioncell更改值为true或false时,该值将设置为testBooleanColumn中的可编辑单元格

How to do this? 这个怎么做? any hint ? 有什么提示吗? or sample code for this use case ? 或此用例的示例代码?

There are three ways to do that: 有三种方法可以做到这一点:

  1. Use a CompositeCell with an ClickTextCell and a SelectionCell and override the render method of the CompositeCell to render only the ClickTextCell. CompositeCellClickTextCellSelectionCell一起使用,并重写CompositeCell的render方法以仅呈现ClickTextCell。
    When the ClickTextCell is clicked it will automatically call the ValueUpdater . 单击ClickTextCell时,它将自动调用ValueUpdater
    In the update function of the ValueUpdater you have to set some boolean value in your ClickTextCell. 在ValueUpdater的更新功能中,您必须在ClickTextCell中设置一些布尔值。 Then you have to check in the render method of your CompositeCell this boolean value and if it is set, then render the SelectionCell instead of the ClickTextCell. 然后,您必须在CompositeCell的render方法中检查此布尔值,如果已设置,则呈现SelectionCell而不是ClickTextCell。

  2. Create a custom cell extending AbstractEditableCell for example (see this tutorial ) and implement the functionality yourself. 例如,创建一个扩展AbstractEditableCell的自定义单元(请参阅本教程 )并自己实现该功能。 You can check out the code for SelectionCell and EditTextCell and copy most of it. 您可以签出SelectionCellEditTextCell的代码并复制其中的大部分代码。 Basically you have to have some kind of a flag which is set when the cell gets focus. 基本上,您必须具有在单元格获得焦点时设置的某种标志。 In the render method you have to either display a dropdownlist or just a text. 在render方法中,您必须显示一个下拉列表或仅显示一个文本。

  3. Extend either EditTextCell or SelectionCell and implement the missing functionality. 扩展EditTextCell或SelectionCell并实现缺少的功能。 The advantage is that you can probably re-use some of the render methods and you don't have to write the complete render code yourself. 优点是您可以重用某些渲染方法,而不必自己编写完整的渲染代码。

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

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