private void detach() { if( tr != null ) { if( tr.getParentElement() != null ) tr.removeFromParent(); } if( parent != null ) { parent.childs.remove( this ); parent = null; } }
private void detach() { if( tr != null ) { if( tr.getParentElement() != null ) tr.removeFromParent(); } if( parent != null ) { parent.childs.remove( this ); parent = null; } }
/** * Borrowed from CellTable#onBrowserEvent2(Event event) * * @param target * @return */ public static int identifyRow(Element target) { // Find the cell where the event occurred. TableCellElement tableCell = findNearestParentCell(target); if (tableCell == null) { return -1; } // Determine if we are in the header, footer, or body. Its possible that // the table has been refreshed before the current event fired (ex. change // event refreshes before mouseup fires), so we need to check each parent // element. Element trElem = tableCell.getParentElement(); if (trElem == null) { return -1; } TableRowElement tr = TableRowElement.as(trElem); Element sectionElem = tr.getParentElement(); if (sectionElem == null) { return -1; } int row = tr.getSectionRowIndex(); return row; }
@PatchMethod static int getSectionRowIndex(TableRowElement element) { if (element == null) { return -1; } Element parent = element.getParentElement(); if (parent == null) { return -1; } for (int i = 0; i < parent.getChildNodes().getLength(); i++) { if (element.equals(parent.getChildNodes().getItem(i))) { return i; } } return -1; }
@PatchMethod static int getSectionRowIndex(TableRowElement element) { if (element == null) { return -1; } Element parent = element.getParentElement(); if (parent == null) { return -1; } for (int i = 0; i < parent.getChildNodes().getLength(); i++) { if (element.equals(parent.getChildNodes().getItem(i))) { return i; } } return -1; }
@PatchMethod static TableRowElement insertRow(TableElement e, int index) { NodeList<TableRowElement> rows = e.getRows(); TableRowElement newRow = Document.get().createTRElement(); if (rows.getLength() < 1) { TableSectionElement tbody = Document.get().createTBodyElement(); e.appendChild(tbody); tbody.appendChild(newRow); } else { if (index == -1 || index >= rows.getLength()) { TableRowElement after = rows.getItem(rows.getLength() - 1); after.getParentElement().insertAfter(newRow, after); } else { TableRowElement before = rows.getItem(index); before.getParentElement().insertBefore(newRow, before); } } return newRow; }
@PatchMethod static TableRowElement insertRow(TableElement e, int index) { NodeList<TableRowElement> rows = e.getRows(); TableRowElement newRow = Document.get().createTRElement(); if (rows.getLength() < 1) { TableSectionElement tbody = Document.get().createTBodyElement(); e.appendChild(tbody); tbody.appendChild(newRow); } else { if (index == -1 || index >= rows.getLength()) { TableRowElement after = rows.getItem(rows.getLength() - 1); after.getParentElement().insertAfter(newRow, after); } else { TableRowElement before = rows.getItem(index); before.getParentElement().insertBefore(newRow, before); } } return newRow; }