简体   繁体   English

动态更新GWT的CellTable中的SelectionCell

[英]Dynamically update SelectionCell in CellTable in GWT

I am using gwt sdk 2.6.0 . 我正在使用gwt sdk 2.6.0。

Please find my simplified problem statement below, 请在下面找到我的简化问题说明,

I have a CellTable containing Column as A and B . 我有一个CellTable包含Column作为A和B。 Col A contains non-editable value and Col B contains dropdown (SelectionCell) . 列A包含不可编辑的值,列B包含下拉列表(SelectionCell)。

Col B dropdown options should be different in each row depending upon value of Col A . 根据Col A的值,每行Col B的下拉选项应该不同。

I am able to render fixed value for dropdown options (ie: same for all rows) but not dynamically different option as per my above description . 我能够为下拉选项(例如,所有行都相同)呈现固定值,但是根据我的上述描述却无法动态地改变选项。

eg: if Col A contains value as 'a' then , Col B will contain dropdown with options {x,y} and if Col A contains value as 'b' then , Col B will contain dropdown with options {y,z} ... which means set of values present in dropdown (in Col B) in each row changes depending on value of column A 例如:如果Col A包含值为'a',则Col B将包含带有选项{x,y}的下拉列表,如果Col A包含具有值'b'的下拉列表,则Col B将包含带选项{y,z}的下拉列表。 ..表示每行下拉菜单(在B列中)中存在的一组值根据A列的值而变化

You cannot show different options in each row using a SelectionCell. 您不能使用SelectionCell在每一行中显示不同的选项。 You will have to create your own custom cell that renders different options based on the object that is passed to it. 您将必须创建自己的自定义单元,该单元根据传递给它的对象来呈现不同的选项。

UPDATE: 更新:

You will need to extend the SelectionCell and 您将需要扩展SelectionCell和

(a) Add a method that sets the rules for including options in the dropdown list based on the information available to the cell. (a)添加一种方法,该方法根据单元格可用的信息来设置将选项包括在下拉列表中的规则。 This can be either the current value (String) that is passed to this cell (eg if the value is "red" or "green" or "blue", show options "red, green, blue"), or a row number (eg for rows 1, 2 and 5 show options "red, green, blue"). 这可以是传递给此单元格的当前值(字符串)(例如,如果值是“ red”,“ green”或“ blue”,显示选项“ red,green,blue”)或行号(例如,对于第1、2和5行,显示选项“红色,绿色,蓝色”)。 Most likely, you will have to pass a reference to a data structure that you update elsewhere. 最可能的是,您将必须传递对在其他位置更新的数据结构的引用。

(b) Override the render method to show options based on the rules set above. (b)重写render方法以显示基于上述规则的选项。

Alternatively, you can add methods for setting the options, and then call these methods when a cell in a different column is updated. 或者,您可以添加用于设置选项的方法,然后在更新另一列中的单元格时调用这些方法。

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

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