Question

Question: How to append more rows to the celltable/datagrid? I think there must be a way to append rows directly to the table beyond the current size of the table.

Actually, the statements above sifficiently and succinctly completes the question.

Redundant info

But, to escape the delete-trigger happy, the following information is provided, which is redundant because if you knew the answer, you would already know the issues. But, if you need to read the following, I would rather you invest significant amount of time to investigate and understand the issues, before answering. So the following info is only for averting the trigger happy.

If the table currently has N rows, setRowData(newRows) will only put newRows into the table up to the Nth row.

If it detects that the number of rows to be placed exceeds the last row index of the table, it would replace the whole table with the new rows, and the old rows removed.

If it detects that you are not putting the rows at the start of the page, it would replace the whole table with tne new rows. To avert that you have setPageStart(getRowCount()).

I had tried the following, which simply replaces the table with new rows, discarding the old.

public void appendRecords(T list)
{
  int n = getRowCount();
  setRowCount(n + list.size());
  setPageStart(n);
  setRowData(n, list);
}

My only recourse is to let the dataprovider memorise the list and any change to the list would go thro the dataprovider, where the dataprovider would replace the table's list everytime a change occurs.

Was it helpful?

Solution

setRowData(list) is the exact equivalent of setRowCount(list.size()); setRowData(0, list); (the setRowCount call here is to shrink the table if needed, because setRowData will always expand it so that the data fits in).

If you want to append some rows, then setRowData the list of new rows at the last index (getRowCount).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top