Is it possible to make the entire row of a Wicket DataTable clickable ? if so, how ? I've seen examples of how to make a cell clickable by extending the PropertyColumn class, which is fairly easy but can't find an easy solution for the entire row.
1 Answer
this do the work.
//override this method of the DataTable class
@Override
protected Item<T> newRowItem(String id, int index, final IModel<T> model) {
Item<T> rowItem = new Item<T>(id, index, model);
rowItem.add(new AjaxEventBehavior("onclick") {
private static final long serialVersionUID = 6720512493017210281L;
@Override
protected void onEvent(AjaxRequestTarget target) {
//callback or do some stuff
}
});
return rowItem;
}
-
Very helpful answer. Additionally, overriding this method allows me set the markup id of each row, which his very helpful in my case as I have to trigger a jQuery event to highlight the newly inserted row which triggered a refresh of the DataTable. May 30, 2012 at 6:39
-
-
by the model, internally wicket have a track of the relation between the rows and objects– osdamvAug 23, 2012 at 17:03
-
Is there any way I can return a document on a row click? I get Ajax errors when I try to return a ResourceStreamRequestHandler (that contains a PDF I generate on the fly when you click the row).– JohnclMar 31, 2014 at 10:54
-
@Johncl i think so, i would try to make my own ajaxbehaivor, however about a year i don't program in wicket :(– osdamvApr 1, 2014 at 15:38
PropertyColumn
implementation. You could have a look atnewRowItem
in theDataTable
class and the the overridden methodnewRowItem
in theDataGridView
.