A small feature request: it seems that in the TreeGrid, when you are dragging items from a ListGrid onto a TreeGrid the TreeGrid does not highlight the item in the tree that will currently be dropped on if you let go of the mouse. It does provide a over icon capability, so you can show a different icon when the mouse is over, but it would be nice if the control also highlighted the text in a different color so the user can clearly see where their items will be dropped onto when they let go.
Override getBaseStyle to return a different style series for the row that the mouse is currently over (getEventRow()) during a drag and drop interaction (EH.getDragTarget() != null is one way to detect this). Add a dropMove handler that calls refreshRow every time a new row is entered.
This works only when the folder already has few nodes, as folderOpenEvent is only fired when it has nodes under it.
Also, this has a limitation of changing style when the user simply tries to open a folder, even after putting the condition treeGrid.getDropFolder().equals(event.getNode()).
Other events like DragRepositionMove also don’t seem to work.Can somebody suggest any ways of implementing the requirement,please ?
Basically you need to refresh the row as well as setting the custom style.
If you add a call to refreshRow() or markForRedraw() or redraw() to your first implementation it should work.
Also note that rather than calling ‘setCustomStyle()’, you may want to override ‘getCellStyle’ or ‘getBaseStyle’ or ‘getCellCSSText’ to return your custom styling if the row in question is the drop target folder. This method will be reevaluated whenever the row is refreshed so is “dynamic”.
If you use ‘setCustomStyle()’ you would have to take an additional step of resetting the style back to the default once the folder is no longer the drop target.
Thanks for the help.As advised, I tried the below piece of code:
treeGrid = new TreeGrid(){
protected String getBaseStyle(ListGridRecord record, int rowNum, int colNum) {
String baseStyle = super.getBaseStyle(record, rowNum, colNum);
TreeNode dropFolder = treeGrid.getDropFolder();
if (null != dropFolder && null != record) {
int id = dropFolder.getAttributeAsInt("id").intValue();
int recId = record.getAttributeAsInt("id").intValue();
if (id == recId)
baseStyle = "treeCellSelectedOver";
}
return baseStyle;
}
};
treeGrid.addDragMoveHandler(new DragMoveHandler() {
public void onDragMove(DragMoveEvent event) {
int id = treeGrid.getDropFolder().getAttributeAsInt("id");
treeGrid.refreshRow(getTreeNodeRowNumber(id));
}
});
This works fine most of the times. However, I see an issue in one of the scenarios as mentioend below:
Create a new folder in the tree.
Using mouse, hover over the different nodes and this folder.
Most of the times, the style returned by “getBaseStyle” is “treeCell” and all the nodes and folder show style “treeCellSelectedOver” when overed upon
At one instance, when we hover upon the newly created folder, treeGrid.getDropFolder() returns the newly created folder, making the “getBaseStyle” method return “treeCellSelectedOver” and the folder in UI shows “treeCellSelectedOverSelectedOver” applied to it, which shows distorted text.
Please note that dragging has not started yet and treeGrid.getDropFolder returns the newly created folder.
I suspect it to be an issue with the API TreeGrid.getDropFolder. Please confirm if I am correct and suggest any corrections needed here.
getBaseStyle will have styling suffixes (“selected”, “over” etc) applied to it.
This means if you return “treeCellSelectedOver”, and the row in question is selected / has the mouse over, you’ll get additional suffixes as you’re describing.
For this case where you want the complete style (not just the base style), use getCellStyle() and return this style name.