0
votes

I am beginner in GWT application development. I have searched about CellTable online. Didn't got any explaination other than some examples.

Now I really want to know what exactly the DataProvider does in CellTable? Also would like know more about celltable and if there are any resources available for the same??

1

1 Answers

5
votes

The dataprovider holds your model. Whenever you change your model (for instance, a list of object mapped to your cellTable), it will be in charge of updating the display.

It acts as a controller between your display (the cellTable) and the model (i.e. a list of objects, typically a list of shared objects coming from your back-end).

Here is an example with a listdataprovider:

@UiField(provided = true)
protected CellTable<TableRowDataShared> cellTable;

protected ListDataProvider<TableRowDataShared> dataProvider = new ListDataProvider<TableRowDataShared>();

public void init() {
    dataProvider.addDataDisplay(cellTable);
    // init your cellTable here...
}

public void onModelUpdate(List<TableRowDataShared> newData) {
    dataProvider.getList().clear();
    dataProvider.getList().addAll(newData);
    dataProvider.flush();
    dataProvider.refresh();
    cellTable.redraw();
}