PDA

View Full Version : [FIXED] [1.2.3] TreeTable DND - insert ends up as append



googelybear
1 Apr 2009, 2:20 PM
When using DND features on a TreeTable, items dropped as insert are appended instead of inserted.
I've located the bug In the render method of the TreeTableItemUI class: the div element of a new item is appended instead of inserted. Plese review.

This issue has been reported here: http://extjs.com/forum/showthread.php?p=311436#post311436
Here's the fixed version:


public void render(Element target, int index) {
if (item.isRoot() == true) {
return;
}

item.setElement(DOM.createDiv());
item.setStyleName("my-treeitem");
DOM.insertChild(target, item.getElement(), index);

TableColumnModel cm = getTreeTableItem().getTreeTable().getColumnModel();

// DOM.appendChild(item.getParentItem().getContainer(), item.getElement());
// should be an insert not an append !!!!!!
DOM.insertChild(item.getParentItem().getContainer(), item.getElement(), index);
DOM.setInnerHTML(item.getElement(), Markup.TREETABLE_ITEM);
tableItemEl = item.el().firstChild().dom;

rowTableEl = DOM.getFirstChild(tableItemEl);
rowTrEl = El.fly(rowTableEl).getSubChild(2);
updateCellValues(0, DOM.getFirstChild(rowTrEl), cm.getColumn(0).getAlignment());
itemEl = new El(El.fly(rowTrEl).getSubChild(4));
Element td = itemEl.subChild(3).dom;
indentEl = DOM.getFirstChild(td);
jointEl = DOM.getNextSibling(td);
jointDivEl = DOM.getFirstChild(jointEl);
checkEl = DOM.getNextSibling(DOM.getNextSibling(jointEl));
checkDivEl = DOM.getFirstChild(checkEl);
iconEl = DOM.getNextSibling(checkEl);
iconDivEl = DOM.getFirstChild(iconEl);
textEl = DOM.getNextSibling(iconEl);
textSpanEl = DOM.getFirstChild(textEl);
Element tbl = DOM.getFirstChild(item.getElement());
containerEl = new El(DOM.getNextSibling(tbl));

int numColumns = cm.getColumnCount();
cells = new Element[numColumns];

for (int i = 1; i < numColumns; i++) {
cells[i] = DOM.createTD();
DOM.appendChild(rowTrEl, cells[i]);

DOM.setElementProperty(cells[i], "className", "my-treetbl-cell");
DOM.setElementAttribute(cells[i], "index", String.valueOf(i));

Element overflowDiv = DOM.createDiv();
DOM.setElementProperty(overflowDiv, "className", "my-treetbl-cell-overflow");
DOM.appendChild(cells[i], overflowDiv);
Element textDiv = DOM.createDiv();

String textStyle = "my-treetbl-cell-text";
if (((TreeTableItem) item).getCellStyle(i) != null) {
textStyle += " " + ((TreeTableItem) item).getCellStyle(i);
}
DOM.setElementProperty(textDiv, "className", textStyle);
DOM.appendChild(overflowDiv, textDiv);
updateCellValues(i, cells[i], cm.getColumn(i).getAlignment());
}

boolean checkable = getTreeTableItem().getTreeTable().getCheckable();
El.fly(checkEl).setVisible(checkable);

onValuesChanged(getTreeTableItem().getTreeTable(), getTreeTableItem().getRenderedValues());

onIconStyleChange(item.getIconStyle());

if (item.isChecked()) {
onCheckChange(true);
}

El.fly(indentEl).setWidth(getIndent());

if (!GXT.isIE) {
DOM.setElementPropertyInt(item.getElement(), "tabIndex", 0);
}

updateJointStyle();
item.disableTextSelection(true);

}

sven
6 Apr 2009, 1:19 PM
Fixed in SVN.