Do in this way using DSCallback
.
DataSource#removeData()
is a async call to the server. Either redraw the grid again or fetch the data again after getting response from server that record has been deleted in DSCallback
.
DataSource dataSource = grid.getDataSource();
dataSource.removeData(record,new DSCallback() {
@Override
public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest){
Record[] records=dsResponse.getData();//deleted records
grid.fetchData();//fetch data again
}
});
Please have a look at this thread Removing local record from listGrid without committing
Try with ListGrid#saveAllEdits() before fetching the data again.
You can try with ListGrid#removeSelectedData() to remove the currently selected records from this component. If this is a databound grid, the records will be removed directly from the DataSource.