how to get latest UI data after sorting the tableViewer or moving one column [message #637937] |
Tue, 09 November 2010 12:12 |
Ping Luo Messages: 8 Registered: January 2010 Location: Beijing |
Junior Member |
|
|
hi guys,
sorry to interrupt you again. maybe a simple question.
In TableViewer, after set the column moveable, we can change the columns sequence, such as drag the whole last column to be the first one. In UI, we can see the table item data has changed(the sequence), now I want to save all input data as it shows in UI, but the tableViewer.getInput() call always return the same old intput model data. here is the code:
Object input = tableViewer.getInput();
Table table = tableViewer.getTable();
TableColumn[] columns = table.getColumns();
for(TableColumn column : columns){
System.out.print(column.getText() + " ");
System.out.println();
}
System.out.println("data");
TableItem[] items2 = tableViewer.getTable().getItems();
for(TableItem item : items2){
for(int i = 0; i < columns.length; i++){
System.out.print(item.getText(i) + " ");
}
System.out.println();
}
the same situation is when using sorter, after change the order of lines, it seems that the TableViewer only change the way how to show the input data, now I want to save the changed table data(at least the sequence is changed) , can you give some suggestion?
thanks,
Ping
|
|
|
|
Re: how to get latest UI data after sorting the tableViewer or moving one column [message #638121 is a reply to message #637944] |
Wed, 10 November 2010 01:37 |
Ping Luo Messages: 8 Registered: January 2010 Location: Beijing |
Junior Member |
|
|
Hi Thomas,
actually I have content and label provider, and also, each column has its own cellEditor. after I change one cell text, I can use the code Object input = tableViewer.getInput(); to get the latest model data.
My question is, after exchange two column, such as column1, column2, has been changed to column2, column1, the Data in UI seems be changed, but when I still use Object input = tableViewer.getInput() , I always get the old model(I want to get the data like it shows in UI). here is the example:
column1 column2 column 3
11 12 13
21 22 23
after move the column2 to be the first one, in UI it shows:
column2 column1 column 3
12 11 13
22 21 23
now I want to save the new data, my table input is a EList<EList<String>>, not use any POJO class.
getting the input via the table items is not the way, I just want to have a try in this case if I can use table items to get the sequence changed data, but it failed too.
any other suggestions?
thanks,
Ping
|
|
|
|
Powered by
FUDForum. Page generated in 0.03525 seconds