/ / Kendo UI TreeView habilita / deshabilita el evento dragAndDrop dinámicamente - javascript, jquery, kendo-ui, telerik, kendo-treeview

Kendo UI TreeView habilita / deshabilita el evento dragAndDrop dinámicamente - javascript, jquery, kendo-ui, telerik, kendo-treeview

Me gustaría saber cómo habilitar la funcionalidad dragAndDrop a través de javascript / jQuery dinámicamente.

Sé que esto se puede hacer en el momento de la inicialización con el siguiente fragmento de código:

$("#treeview").kendoTreeView({
dragAndDrop: true,
dataSource: [
{ text: "foo" },
{ text: "bar" }
]
});

Pero quiero esta funcionalidad dragAndDrop con el botón de alternar, me refiero a habilitar / deshabilitar la funcionalidad dragAndDrop en los nodos del árbol con un clic de botón.

Cualquier fragmento de código me ayuda mucho.

Respuestas

1 para la respuesta № 1

Por favor, intente con el siguiente fragmento de código.

<body>
<div id="treeview"></div>
<br />
s
Drag Drop Enabled:-
<input type="checkbox" id="chkDragNDrop" />
<script>
$("#treeview").kendoTreeView({
dragAndDrop: true,
dragstart: onDragStart,
dataSource: [
{ text: "foo" },
{ text: "bar" }
]
});
function onDragStart(e) {
if ($("#chkDragNDrop").prop("checked") == false) {
e.preventDefault();
}
}
</script>
</body>

Déjame saber si hay alguna preocupación.