Thursday, June 26, 2014

Re: Custom attributes for td elements of CellTable



Am Mittwoch, 18. Juni 2014 12:11:09 UTC+2 schrieb Thomas Broyer:


On Wednesday, June 18, 2014 11:51:20 AM UTC+2, Christian Plätzinger wrote:
Hi all,

I'm trying to make some of my GWT CellTables to be responsive using CSS. To be more precise I'm trying to implement the "No More Table" example found at http://elvery.net/demo/responsive-tables/. Works well except the fact that I have to set the data-title attribute in the HTML <td> element of my cells. Does anybody has an idea how to do that?

First, I think you could modify the CSS to read the attribute from a <div> element within the <td>; you could then override the render() method of your Columns to wrap the cell into such a <div data-title="{columnTitle}">.

I tried it but it does not work.
 

Otherwise, and to directly answer your question, you can provide your own CellTableBuilder. You could extend DefaultCellTableBuilder and override renderCell to add the data-title attribute to the ElementBuilderBase passed as the first argument; but that element is actually a <div>, so you'd have to adapt the CSS too. Or you could copy/paste DefaultCellTableBuilder and then modify buildRowImpl to add the attribute right onto the <td>; you'd have to find a way to retrieve the column title though (from the Column, or from a List<String> passed to the CellTableBuilder).

Maybe we should add an addCellAttributes, similar to the existing addRowAttributes, to make this kind of customization easier… Feel free to file a request for enhancement on the issue tracker, and/or even better, provide the patch (should be relatively easy to implement I suppose)
I added a custom implementation of DefaultCellTableBuilder and modified the buildRowImpl. Since we already used custom Column classes it was easy to add the string attribute to the Column classes.

Thanks for your answer :-).

Cheers
Christian
 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment