How to add clicker manipulator to celltablebuilder dungeon

I can create custom rows using celltablebuilder. When you click on a specific anchor cell, I can create additional substrings for this row. This subset has buttons, when I click on the button, I do some action. I can add buttons with a click manipulator to the dungeon, but when I click on a button, nothing happens, the click manipulator does not shoot.

Someone can help.

protected void buildRowImpl(GridDTO rowValue, int absRowIndex ) { buildRows(rowValue, absRowIndex, true); if (showingFriends.contains(rowValue.getComponentId())) { buildAdditonalRows( absRowIndex, gridDTO); } } private void buildAdditonalRows(int index, GridDTO rowValue, ){ TableRowBuilder row = startRow(); td = row.startTD(); if(rowValue.getXpath() != null){ //td.text(rowValue.getXpath()); renderCell(td, createContext(1), cellTable.getColumn(1), rowValue); }else{ td.text(""); } td.endTD(); td = row.startTD(); Button button = new Button (); button.setText("Save"); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Window.alert("ssss"); } }); DivBuilder div = td.startDiv(); div.html(new afeHtmlBuilder().appendHtmlConstant(button.toString()).toSafeHtml()); div.end(); td.endTD(); row.endTR(); } 
+4
source share
2 answers

CellPreviewEvent provides a subindex. You can use it to get the dungeon value. Usage example:

 dataGrid.addCellPreviewHandler(new CellPreviewEvent.Handler<TreeItem>() { @Override public void onCellPreview(final CellPreviewEvent<TreeItem> event) { if(event.getNativeEvent().getType().equals(BrowserEvents.CLICK)){ if(event.getContext().getSubIndex()>0){ event.getValue().getChild(event.getContext().getSubIndex()-1); } } } }); 

Or you can provide a custom implementation of CellPreviewEvent.Handler using the selectionMode method. For more details you can see AbstractHasData

+1
source

I had a similar situation when I needed a widget inside a cell to listen for click events ... I found out that the widget does not respond to events after you inserted it into the cell (in other words, only the actual HTML that makes up for the widget, placed in a cell; processing of any events is not enabled). The work around is to add events to the cell (you can create your own class of cells for this particular widget and override OnBrowserEvent to listen for events.)

See GWT: Adding a Custom Widget to Events with a list of tablets of custom widgets for a more eloquent explanation and sample code.

0
source

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


All Articles