gwt-celltable


How to add clickhandler to the subrow of the celltablebuilder


I am able to build custom rows with celltablebuilder. When clicking on a particular anchor cell, I am able to build additional subrows for that row. This subrow has buttons, when clicking on the button I have do some action. I am able to add buttons with clickhandler in the subrow, but when clicking on the button nothing is happening clickhandler is not firing.
Can anybody please 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();
}
CellPreviewEvent provides subindex. You can use it to get subrow value.
Example usage :
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 custom CellPreviewEvent.Handler implementation with selectionMode. For more details you can look at AbstractHasData
I had a similar situation where i needed a widget inside a cell to listen for click events... What i found out is that the widget doesn't respond to events once you inserted it into a cell (In other words, only the actual HTML that makes up for the widget gets put into the cell, any kind of event handling isn't included). The work around is to add the events to the Cell (You can make a custom cell class for that particular cell-widget and override OnBrowserEvent to listen for events.)
See GWT: On adding custom widget to celltable losing events of the custom widgets for a more eloquent explanation and example code.

Related Links

GWT - How to display String[][] array in CellTable or DataGrid
How to givie tooltip for each cell for Datagrid in GWT
How to add clickhandler to the subrow of the celltablebuilder
How apply different style to EditTextCell after editing the cell
Nested Grid in GWT
How to render a GWT widget with a clickhandler GWT with a custom table builder?

Categories

HOME
list
facebook-messenger
yii
redmine
theano
risk-management
google-play-services
haxe
gtk
match
erd
tiff
pushdown-automaton
trace32
jpa-2.0
temperature
android-5.1.1-lollipop
asciimath
cocos2d-android
nullreferenceexception
deepfreeze
raml
opam
weex
coreldraw
fido-u2f
multi-upload
channel
perfino
basex
php-5.3
miniprofiler
cube
locks
xenapp
mapnik
riotjs
osx-lion
polyml
db2-luw
express-session
rails-postgresql
jfxtras
wdk
telephonymanager
vesta
destroy
libreoffice-writer
datediff
android-webservice
emacs25
decoder
p6spy
ftp-client
strpos
exists
gridbaglayout
ruby-on-rails-4.1
extend
netdatacontractserializer
supercomputers
gql
sequence-sql
cache-manifest
com0com
web-api
tidyr
incron
dos2unix
adwords-apiv201402
nesper
producer
coding-efficiency
maven-central
nodeload
mft
facebook-game-groups
insertonsubmit
chartfx
flv
sly-scroller
towers-of-hanoi
idispatch
onconfigurationchanged
image-scanner
kolite
n-queens
filelock
odac
aspbutton
3270
comment-conventions

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App