GWT - 如何将更多行附加到单元格表/数据网格
问题: 如何向单元格表/数据网格追加更多行? 我认为必须有一种方法可以将超出表当前大小的行直接追加到表中。
事实上,上面的陈述已经足够简洁地完成了这个问题。
冗余信息
但是,为了避免删除触发快乐,提供了以下信息,这是多余的,因为如果您知道答案,您就已经知道问题了。但是,如果您需要阅读以下内容,我宁愿您在回答之前投入大量时间来调查和理解问题。所以以下信息只是为了避免触发快乐。
如果表当前有 N 行,setRowData(newRows) 只会将 newRows 放入表中,直到第 N 行。
如果它检测到要放置的行数超过表的最后一行索引,它将用新行替换整个表,并删除旧行。
如果它检测到您没有将行放在页面的开头,它将用新行替换整个表。为了避免您有 setPageStart(getRowCount())。
我尝试了以下方法,它只是用新行替换表,丢弃旧行。
public void appendRecords(T list)
{
int n = getRowCount();
setRowCount(n + list.size());
setPageStart(n);
setRowData(n, list);
}
我唯一的办法是让数据提供者记住列表,对列表的任何更改都将通过数据提供者,其中数据提供者将在每次发生更改时替换表的列表。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
setRowData(list)
与setRowCount(list.size()) 完全相同; setRowData(0, list);
(这里的setRowCount
调用是为了在需要时缩小表格,因为setRowData
总是会扩展它以便数据适合)。如果您想追加一些行,请
setRowData
最后一个索引处的新行列表 (getRowCount
)。setRowData(list)
is the exact equivalent ofsetRowCount(list.size()); setRowData(0, list);
(thesetRowCount
call here is to shrink the table if needed, becausesetRowData
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
).