this.client = client;
this.paintableId = uidl.getStringAttribute("id");
this.immediate = uidl.getBooleanAttribute("immediate");
- this.totalRows = uidl.getIntAttribute("totalrows");
+ int newTotalRows = uidl.getIntAttribute("totalrows");
+ if(newTotalRows != totalRows) {
+ this.totalRows = newTotalRows;
+ if(initializedAndAttached)
+ tBody.setContainerHeight();
+ }
+
this.pageLength = uidl.getIntAttribute("pagelength");
if (pageLength == 0)
pageLength = totalRows;
updateBody(rowData, uidl.getIntAttribute("firstrow"), uidl
.getIntAttribute("rows"));
} else {
- getTBody().renderInitialRows(rowData,
+ tBody = new IScrollTableBody();
+
+ tBody.renderInitialRows(rowData,
uidl.getIntAttribute("firstrow"),
- uidl.getIntAttribute("rows"), totalRows);
+ uidl.getIntAttribute("rows"));
bodyContainer.add(tBody);
initialContentReceived = true;
if (isAttached()) {
}
}
- private IScrollTableBody getTBody() {
- if (tBody == null || totalRows != tBody.getTotalRows()) {
- if (tBody != null)
- tBody.removeFromParent();
- tBody = new IScrollTableBody();
- }
- return tBody;
- }
-
private void updateActionMap(UIDL c) {
Iterator it = c.getChildIterator();
while (it.hasNext()) {
* "simulates" very large table, keeping spacers which take room of
* unrendered rows.
*
- * @author mattitahvonen
- *
*/
public class IScrollTableBody extends Panel {
private boolean initDone = false;
- private int totalRows;
-
Element preSpacer = DOM.createDiv();
Element postSpacer = DOM.createDiv();
return DOM.getElementPropertyInt(preSpacer, "offsetWidth");
}
- public void renderInitialRows(UIDL rowData, int firstIndex, int rows,
- int totalRows) {
- this.totalRows = totalRows;
+ public void renderInitialRows(UIDL rowData, int firstIndex, int rows) {
this.firstRendered = firstIndex;
this.lastRendered = firstIndex + rows - 1;
Iterator it = rowData.getChildIterator();
protected void onAttach() {
super.onAttach();
+ setContainerHeight();
+ }
+
+ /**
+ * Fix container blocks height according to totalRows to avoid "bouncing" when scrolling
+ */
+ private void setContainerHeight() {
fixSpacers();
- // fix container blocks height to avoid "bouncing" when scrolling
DOM.setStyleAttribute(container, "height", totalRows
* getRowHeight() + "px");
}
* (totalRows - 1 - lastRendered) + "px");
}
- public int getTotalRows() {
- return totalRows;
- }
-
public int getRowHeight() {
if (initDone)
return rowHeight;