This is a migrated thread and some comments may be shown as answers.

Treeview Dragging - Custom Hint

1 Answer 263 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
don
Top achievements
Rank 1
don asked on 02 May 2013, 04:27 PM
Is there a way to set the hint when dragging a treeview node in a similar manner to how it's set when using the draggable plugin...without using the draggable plugin? My needs are pretty simple - I have a checkbox on my node, and I would like to hide it during the drag event. Here is some relevant code (I would like to hide the div with class "folder-check"):  

<script id="treeview-template" type="text/kendo-ui-template">
    <div class="FolderTemplate">
        <div class="folder-check checkbox-false"></div>
        <div class="folder-details">
            <input type="checkbox" />
            <span>#= item.Name # (#= item.ItemCount #)</span> 
        </div>
        <div style="clear:both;"></div>
    </div>
</script>

Folders = new kendo.data.HierarchicalDataSource(dataSourceOptions);
    $("#treeview").kendoTreeView({
        dragAndDrop: true,
        dataSource: Folders,
        dataTextField: "Name",
        template: kendo.template($("#treeview-template").html()),
        select: onFolderSelect,
        drop: onFolderDrop,
        dragstart: onFolderDragStart,
        drag: onFolderDrag,
        dataBound: onDataBound
    });

function onFolderDragStart(e) {
    if (this.dataItem(e.sourceNode).IsSpecialFolder)
        e.preventDefault();
}

Thanks so much.

1 Answer, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 03 May 2013, 07:47 AM
Hello Don,

You can modify the drag template by changing the internal templates of the TreeView; however, this functionality may break in later versions, as it is not documented. Here is a jsBin sample that shows how to do that.

The problem will not occur if you are using the out-of-the-box checkboxes support, as shown in this jsBin. If you can style the default treeview rendering to fit your requirements, this is the recommended approach.

Greetings,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
TreeView
Asked by
don
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Share this question
or