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.
making entire row of a wicket datatable clickable
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. –
Latticework
How do you know what object was clicked in the onEvent method? –
Linc
by the model, internally wicket have a track of the relation between the rows and objects –
Nicolette
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). –
Odessa
@Odessa i think so, i would try to make my own ajaxbehaivor, however about a year i don't program in wicket :( –
Nicolette
© 2022 - 2024 — McMap. All rights reserved.
PropertyColumn
implementation. You could have a look atnewRowItem
in theDataTable
class and the the overridden methodnewRowItem
in theDataGridView
. – Dhruv