I've perused the source and can't find an easy way to do this.  I'm hoping
that maybe someone else has done it.

In an app for one customer, I have a table that lists parts that could be
purchased.  It is a subclass of DefaultDataTable.  I pass it in a custom
sortable data provider that wraps a list - so it has all parts in a list.
Then, I have filters above the table that can filter the list to a specific
category of parts.  But if you filter down to a certain category of parts,
some of those columns will be completely empty.  It would be nice to hide
them.  But the table was already created - and it operates off of a static
array of columns.  The column doesn't provide an isVisible mechanism.  Is
there an easy way to hide it, or does the table need to be recreated and
replaced within the ajax link?

The current code is basically like this:

final ListSortableDataProvider dp = new
ListSortableDataProvider(listOfParts, "columnToSortOn");
final PartInfoTable table = new PartInfoTable("table", new
VendorColumnFactory(vendor), vendor, dp);
add(table.setOutputMarkupId(true));

AjaxFallbackLink filterLink = new AjaxFallbackLink("link") {
    private static final long serialVersionUID = 1L;

    @Override
    public void onClick(AjaxRequestTarget target) {
        OrderVendorColumn column = (OrderVendorColumn)
nextFilterableColumn.getObject();
        String valueToFilterOn = (String) item.getModelObject();
        mPartFilter.addFilter(column, valueToFilterOn);
        dp.setList(mPartFilter.filterPartsList(parts));
        if (target != null) {
            target.addComponent(table);
            target.addComponent(LookupPartsPage.this.get("currentFilter"));
            target.addComponent(LookupPartsPage.this.get("addFilter"));
        }
    }
};
filterLink.add(new Label("label", item.getModel()).setRenderBodyOnly(true));


-- 
Jeremy Thomerson
http://www.wickettraining.com

Reply via email to