简体   繁体   中英

Dynamically update SelectionCell in CellTable in GWT

I am using gwt sdk 2.6.0 .

Please find my simplified problem statement below,

I have a CellTable containing Column as A and B . Col A contains non-editable value and Col B contains dropdown (SelectionCell) .

Col B dropdown options should be different in each row depending upon value of Col A .

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

You cannot show different options in each row using a 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

(a) Add a method that sets the rules for including options in the dropdown list based on the information available to the cell. 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"). 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.

Alternatively, you can add methods for setting the options, and then call these methods when a cell in a different column is updated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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