Re: Hook for hiding columns of DataTable?
this is on my list for 1.5, in 1.4/1.3 it would require too many api breaks i think. for now you can just replace the datatable with a new instance. the only state you have to carry over is the current page, so its pretty easy. -igor On Wed, Aug 6, 2008 at 9:45 AM, Ladislav Thon <[EMAIL PROTECTED]> wrote: > I've managed to "solve" similar problem by > > 1. setting a specific CSS class on each column, both in th and td tags (this > can be done by overriding getCssClass() method of AbstractColumn) > > 2. setting a specific CSS class on the table when some columns should be > hidden (this can be done e.g. using an AttributeAppender behavior) > > 3. hiding the columns in CSS, like table.hideFirstColumn .col1 {display: > none} > > Not very nice (quite ugly in fact), but works for my needs. Yours might be > more dynamic though (I basically have only two states, in the first all > columns are shown, in the second few of them are hidden). > > LT > > 2008/8/3 Jeremy Thomerson <[EMAIL PROTECTED]> > >> 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 >> > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hook for hiding columns of DataTable?
I've managed to "solve" similar problem by 1. setting a specific CSS class on each column, both in th and td tags (this can be done by overriding getCssClass() method of AbstractColumn) 2. setting a specific CSS class on the table when some columns should be hidden (this can be done e.g. using an AttributeAppender behavior) 3. hiding the columns in CSS, like table.hideFirstColumn .col1 {display: none} Not very nice (quite ugly in fact), but works for my needs. Yours might be more dynamic though (I basically have only two states, in the first all columns are shown, in the second few of them are hidden). LT 2008/8/3 Jeremy Thomerson <[EMAIL PROTECTED]> > 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 >
Hook for hiding columns of DataTable?
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