/*-{
var vScroll = esc.@com.vaadin.client.widgets.Escalator::verticalScrollbar;
var vScrollElem = vScroll.@com.vaadin.client.widget.escalator.ScrollbarBundle::getElement()();
-
+
var hScroll = esc.@com.vaadin.client.widgets.Escalator::horizontalScrollbar;
var hScrollElem = hScroll.@com.vaadin.client.widget.escalator.ScrollbarBundle::getElement()();
-
+
return $entry(function(e) {
var target = e.target || e.srcElement; // IE8 uses e.scrElement
-
+
// in case the scroll event was native (i.e. scrollbars were dragged, or
// the scrollTop/Left was manually modified), the bundles have old cache
// values. We need to make sure that the caches are kept up to date.
return $entry(function(e) {
var deltaX = e.deltaX ? e.deltaX : -0.5*e.wheelDeltaX;
var deltaY = e.deltaY ? e.deltaY : -0.5*e.wheelDeltaY;
-
+
// Delta mode 0 is in pixels; we don't need to do anything...
-
+
// A delta mode of 1 means we're scrolling by lines instead of pixels
// We need to scale the number of lines by the default line height
if(e.deltaMode === 1) {
var brc = esc.@com.vaadin.client.widgets.Escalator::body;
deltaY *= brc.@com.vaadin.client.widgets.Escalator.AbstractRowContainer::getDefaultRowHeight()();
}
-
+
// Other delta modes aren't supported
if((e.deltaMode !== undefined) && (e.deltaMode >= 2 || e.deltaMode < 0)) {
var msg = "Unsupported wheel delta mode \"" + e.deltaMode + "\"";
-
+
// Print warning message
esc.@com.vaadin.client.widgets.Escalator::logWarning(*)(msg);
}
-
+
// IE8 has only delta y
if (isNaN(deltaY)) {
deltaY = -0.5*e.wheelDelta;
}
-
+
@com.vaadin.client.widgets.Escalator.JsniUtil::moveScrollFromEvent(*)(esc, deltaX, deltaY, e);
});
}-*/;
/**
* The table section element ({@code <thead>}, {@code <tbody>} or
* {@code <tfoot>}) the rows (i.e. {@code
- * <tr>
+ *
+ <tr>
* } tags) are contained in.
*/
protected final TableSectionElement root;
* <p>
* <em>Note:</em> In contrast to {@link #reapplyColumnWidths()}, this
* method only modifies the width of the {@code
- * <tr>
+ *
+ <tr>
* } element, not the cells within.
*/
protected void reapplyRowWidths() {
// init default dimensions
setHeight(null);
setWidth(null);
+
+ publishJSHelpers(root);
+ }
+
+ private int getBodyRowCount() {
+ return getBody().getRowCount();
}
+ private native void publishJSHelpers(Element root)
+ /*-{
+ var self = this;
+ root.getBodyRowCount = $entry(function () {
+ return self.@Escalator::getBodyRowCount()();
+ });
+ }-*/;
+
private void setupScrollbars(final Element root) {
ScrollHandler scrollHandler = new ScrollHandler() {
selectMenuPath("Component", "Body rows", "Add third row");
assertFalse(logContainsText("Exception occured"));
}
+
+ @Test
+ public void getBodyRowCountJS() {
+ openTestURL();
+ GridElement grid = $(GridElement.class).first();
+ assertEquals(1000L,
+ executeScript("return arguments[0].getBodyRowCount()", grid));
+ selectMenuPath("Component", "Body rows", "Remove all rows");
+ assertEquals(0L,
+ executeScript("return arguments[0].getBodyRowCount()", grid));
+ selectMenuPath("Component", "Body rows", "Add first row");
+ assertEquals(1L,
+ executeScript("return arguments[0].getBodyRowCount()", grid));
+ }
}