js tree jquery
jsTree
' + name + '
';
list.append(li);
}
});
}).bind("create.jstree", function (e, data) {
var parent_id = data.rslt.parent[0].id;
var lastChar = parent_id.substr(-1); // Selects the last character
if (lastChar != "\\") { // If the last character is not a slash
parent_id = parent_id + "\\"; // Append a slash to it.
}
$.post('/CreateDirectory', { path: parent_id + data.rslt.name }, function (data) {
$.jstree._reference($("#demo1")).refresh(-1);
});
}).bind("rename.jstree", function (e, data) {
var parent_id = data.rslt.obj.attr("id");
var path = data.rslt.obj.attr("id").substring(0, parent_id.lastIndexOf("\\")) + "\\";
var old_name = data.rslt.old_name;
var new_name = data.rslt.new_name;
var fromDir = path + old_name;
var toDir = path + new_name;
$.post('/RenameDirectory', { fromDir: fromDir, toDir: toDir }, function (data) {
$.jstree._reference($("#demo1")).refresh(-1);
});
}).bind("remove.jstree", function (event, data) {
var selected_folder = data.rslt.obj.attr("id");
$.post('/DeleteDirectory', { path: selected_folder }, function (data) {
$.jstree._reference($("#demo1")).refresh(-1);
});
}).bind("move_node.jstree", function (e, data) {
// Cut Paste
var fromDir = data.rslt.o.attr("id"); // old path
var toDir = data.rslt.r.attr("id"); // new path folder path
var is_copy = data.rslt.cy === undefined ? false : true;
$.post('/CutPastDirectory', { SourcePath: fromDir, DestinationPath: toDir, overwriteexisting: false, is_copy: is_copy }, function (data) {
$.jstree._reference($("#demo1")).refresh(-1);
});
});
//end of jstree function
$('#refresh').on('click', function () {
$.jstree._reference($("#demo1")).refresh(-1);
});
});
$(function () { var tree = $("#demo1").jstree({ "ui": { "select_limit": -1, "select_multiple_modifier": "ctrl", "select_range_modifier": "shift" }, "json_data": { "ajax": { "type": 'GET', "dataType": "json", "url": "/getTreeUrl", "data": function (n) { var lists = $(n).parents('ul'); var p = $(lists[0]).prev('a'); var gp = $(lists[1]).prev('a'); // the result is fed to the AJAX request 'data' option return { "parent": $.trim(p.text()), "grandparent": $.trim(gp.text()), "id": $(n).attr('id') }; }, error: function () { alert("Sorry, The requested property could not be found."); } } }, rules: { droppable: ["tree-drop"], multiple: false, deletable: "all", draggable: "all" }, callback: { onselect: function (NODE, TREE_OBJ) { alert(NODE.id); } }, "plugins": ["themes", "json_data", "ui", "crrm", "contextmenu", "cookies"] }).bind("before.jstree", function (event, data) { if (data.func == "remove") { if (!confirm("Are you sure you want to delete ?")) { return false; } } }).bind("select_node.jstree", function (NODE, REF_NODE) { var a = $.jstree._focused().get_selected(); $.get('/GetFiles', { path: a.attr('id') }, function (data) { var list = $('#list'); list.html(''); $.each(data, function (key, value) { var name = value.Name; var path = value.Path; var ext = value.Ext; var li = '
js tree jquery
Reviewed by Bhaumik Patel
on
9:52 PM
Rating: