0
votes

I have a GWT Celltable, wich is updated from database. The new values from database should be added only in new column without to update the other columns. So, after each refresh you can see the new state in new column and compare it with old state.

example of one row (refresh in 10 minutes - so after refresh you have one column more):

data_with_timestamp_01:00

after refresh:

data_with_timestamp_01:00 data_with_timestamp_01:10

after next refresh:

data_with_timestamp_01:00 data_with_timestamp_01:10 data_with_timestamp_01:20

etc.

To add the new column with new data is not the problem. The problem is, that after refresh ListDataProvider change all columns data in the table and not only the last one.

Can sb help me?

2

2 Answers

0
votes

I think a CellTable is the wrong tool for your requirement. You can try to only update the last row by : dataProvider.getList().set(index, dataProvider.getList().get(index));

0
votes

What type of DataProvider are you using? I would use a ListDataProvider, and keep an entry in the list for each row that you are displaying. Each entry would contain a list of values. For example, if each row in the CellTable represents a type of stock then you'd have an entry in the data provider for each type of stock. The stock class would contain a List, with an entry in that list for each timestamp. The Column#getValue method would return the stock price associated with the column that is being updated. When an update is received from the server you can create a new column in the CellTable, and add an entry to each of the lists that represent stock prices.

--Edit--

Just a note to say that you will need to know which entry in the record you want to use in the Column#getValue method, for example, if each row represents a specific stock then there is a list of the stock price for that stock, with each entry in the list representing the price of that stock for a specific timestamp. You will need to identify the list index (i.e., column index) when you create the column ... for example:

final int columnIndex = stockCellTable.getColumnCount();
Column<Stock, String> timestampColumn = new Column<Stock, String>(new TextCell()) {
    @Override
    public String getValue(Stock stock) {
        return stock.getPrice(columnIndex);
    }
}