How to add clickHandler on subRow tables in GWT

I am using the Custom Data Grid from the GWT demo example. http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwCustomDataGrid

Any work works fine. I have substrings inside my rows in a cell table.

I have an anchor cell .. which are in the main line and in the substring.

ClickHandler for the main line works, but not in the substring.

this is my code for this cell

 // ViewDetail. td = row.startTD(); td.className(cellStyles); td.style().trustedColor("blue"); td.style().cursor(Cursor.POINTER); if (isNetworkRow) { //td.text("subRowsAnchor"); } else { } renderCell(td, createContext(19), viewDetailsColumn, rowValue); 

I pass the cell in both cases, either its string or substring so I can see the anchor and its clickHandler also works.

Is there a way that I can distinguish the one on which the anchor was pressed, the main lines or subscript lines.

I was just trying to do a little work. that is, changing the name of the anchor text if it is a sub string .. as u can with in my code .. td.text ..

but then get an error on renderCell ...

Attributes cannot be added after adding HTML or adding a child.

Any idea what might be the solution ...

thanks

+4
source share
1 answer

To distinguish which row was pressed (according to the sample storefront, but should be the same at all), simply rely on which row was selected (provided that you have not redefined / disabled the selection processing).

Set a FieldUpdater to a column (which does itself using a binding cell) and check the selection with getKeyboardSelectedSubRow() , Something like:

 yourColumn.setFieldUpdater(new FieldUpdater<T, String>() { public void update(int index, T object, String value) { if (yourGrid.getKeyboardSelectedRow() != -1 ) { if (yourGrid.getKeyboardSelectedSubRow() > 0) { // Subrow selected. } else { // Main row selected. } } } }); 
+1
source

Source: https://habr.com/ru/post/1479521/


All Articles