No need to create an object, you can use a List<String> to represent a row, and you'd then feed the table with List<List<String>>, which can be easily created from a List<String> using Guava for instance: http://docs.guava-libraries.googlecode.com/git-history/release/javadoc/com/google/common/collect/Iterables.html#paddedPartition(java.lang.Iterable, int)
-- But CellTable might not be the appropriate widget if all you want to do is display a list, partitioned with 4 items per line. You can achieve similar layouts using a CellList and appropriate styling (just beware when upgrading GWT that the structure hasn't changed from the previous version, as it's an "implementation detail" and not guaranteed to stay the same), or create your own widget.
CellTable is best when you have a concept of "rows" that can be selected on their own.
On Monday, August 26, 2013 6:39:15 PM UTC+2, Rogelio Flores wrote:
On Monday, August 26, 2013 6:39:15 PM UTC+2, Rogelio Flores wrote:
Yes, create an object that will have column1, etc as attributes, then create a List<Word> and populate it with your source list however you want to (preferably you might want to send this list like your CellTable will use already populated from the server):public class Word {String column1;String column2;
String column3;String column4;// add setters and getters}List<Word> wordList = new ArrayList<Word>(); // or whatever List implementation you like/need// populate wordList as needed from your source list(s) and add it to your ListDataProvider.// Create column1TextColumn<Word> columnOne = new TextColumn<Word>() {@Override public String getValue(Word word) { return word.getColumn1;} };
On Friday, August 23, 2013 2:24:58 PM UTC-4, Noel Reforma wrote:Hello. I'm trying to build a table (20 rows x 4 columns) of just Strings. I'm using a CellTable and use the ListDataProvider but since my datasource is just a List<String>, I'm having trouble trying to figure out how to split my list so that it will put 20 per column. Initially, I'm thinking about just creating an object that will have column1, column2, column3 and column4 as attributes but I'm not sure if this is the best way to do it.
public Word {
List<String> column1;
List<String> column2;
List<String> column3;
List<String> column4;
}
I guess this is more of a design question. i'm just looking for a cleaner way of doing it. Since I can't do the following because I just have a List<String>, I how can I distinguish the set that will go to col1 and col2...etc.// Create address column. TextColumn<Contact> addressColumn = new TextColumn<Contact>() { @Override public String getValue(Contact contact) { return contact.address; // I cannot do something like this...should I use an Array so I can point to the next column? } };
Thanks. Any advice is appreciated.
NR
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/groups/opt_out.
No comments:
Post a Comment