[Databinding] TableViewer (rows vs columns) [message #649001] |
Mon, 17 January 2011 08:06 |
AJ Messages: 77 Registered: July 2009 |
Member |
|
|
My model or class contains only 4 attributes so can I represent an instance of my class using a fix TableViewer where the name and values of the x, y, and z attributes are displayed as rows and the values of the attribute a are the columns?
public class MyModel {
String x;
String y;
String z;
String a;
....
.....
}
----------------------------
| a | C1 | C2 | C3 |
----------------------------
| x | A1 | A2 | A3 |
----------------------------
| y | B1 | B2 | B3 |
----------------------------
| z | Z1 | Z2 | Z3 |
----------------------------
[Updated on: Mon, 17 January 2011 17:42] Report message to a moderator
|
|
|
Re: [Databinding] TableViewer (rows vs columns) [message #649915 is a reply to message #649001] |
Thu, 20 January 2011 23:24 |
Carsten Habicht Messages: 14 Registered: January 2011 |
Junior Member |
|
|
Does this mean, that your table grows to the right? Adding an object would mean that column C4 is created?
In this case, maybe you could create an intermediate model of the form
public class Line {
String labelColumnA; // Holds X for the first row, Y for the second, etc.
List<String> otherColumns; // Holds An, Bn, Cn for each column n
...
}
Then you can use a label provider that shows the right label according to the column index (index==0 --> labelCol, index>0 --> otherColumns.get(index-1) ).
I'm not sure how Table and TableViewer behave, if you add columns dynamically, but probably it works with some tableViewer.refresh() fiddling.
|
|
|
Powered by
FUDForum. Page generated in 0.03376 seconds