I would like to be able to add a dropdown to a DataTable so that a user can
change the rowsPerPage. Has anyone done this before? If not, what is the best
/ recommended approach?
I tried the following, but I get:
IllegalStateException: Attempt to set model object on null model of component:
rowsFINALDataTable contacts = NEWDataTable("contacts", columns,
contactProvider, rowsPerPage) {
@Override
PROTECTEDItem newRowItem(String id, INTindex, IModel model) {
RETURNNEWOddEvenItem(id, index, model);
}
};
List rows = Arrays._asList_(NEWString[] {"5", "10", "15", "20", "all"});
add(NEWDropDownChoice("rows", rows) {
@Override
PROTECTEDBOOLEANwantOnSelectionChangedNotifications() {
RETURNTRUE;
}
@Override
PROTECTEDVOIDonSelectionChanged(FINALObject newSelection) {
IF(newSelection == "all") {
contacts.setRowsPerPage(100000); // use really big number to
display all
} ELSE{
contacts.setRowsPerPage((Integer) newSelection);
}
}
});
- JA