How to insert 'sub-rows' into a Wicket DataTable How to insert 'sub-rows' into a Wicket DataTable ajax ajax

How to insert 'sub-rows' into a Wicket DataTable


I don't think there is a clean way to do that, you will have to hack the resulting HTML.

I'd attach a custom behavior to the rows that generates the required HTML automatically, something like this:

new AjaxFallbackDefaultDataTable<MyCustomObject>(    id, columns, dataProvider, rowsPerPage){    @Override    protected Item<MyCustomObject> newRowItem(String id,        int index,        final IModel<MyCustomObject> model){        Item<MyCustomObject> item = super.newRowItem(id, index, model);        item.add(new AbstractBehavior(){            private static final long serialVersionUID = 1L;            /**             * {@inheritDoc}             */            @Override            public void onRendered(Component component){                if(model.getObject().isEpicFail()){                    component.getResponse().write(                    "<tr><td colspan=\"3\">This is an epic fail</td></tr>");                }            }        });        return item;    }    private static final long serialVersionUID = 1L;}


If look at class NavigationToolbar (extension, DataTable) when looking from point of view HTML there is one row of html table, object construction is quite different but result is good, other data are presented in HTML row not being a row in sense Java table (from code that navigator isn't part of object table, is external from such point of view.

Nice fragment code to analyse

When my enriched Datatable for data will be platform to visually present reports with subtotal, I know this will be possible