0

我有一个 GWT Celltable,它是从数据库更新的。数据库中的新值应该只添加到新列中,而不更新其他列。因此,每次刷新后,您都可以在新列中看到新状态并将其与旧状态进行比较。

一行的示例(在 10 分钟内刷新 - 因此刷新后您还有一列):

data_with_timestamp_01:00

刷新后:

data_with_timestamp_01:00 data_with_timestamp_01:10

下次刷新后:

data_with_timestamp_01:00 data_with_timestamp_01:10 data_with_timestamp_01:20

等等

用新数据添加新列不是问题。问题是,刷新 ListDataProvider 后会更改表中的所有列数据,而不仅仅是最后一个。

某人可以帮助我吗?

4

2 回答 2

0

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);
    }
}
于 2013-07-22T15:56:22.930 回答
0

我认为 aCellTable是满足您要求的错误工具。您可以尝试只更新最后一行:dataProvider.getList().set(index, dataProvider.getList().get(index));

于 2013-07-22T12:54:46.977 回答