它显示;“未定义”;在树状视图中使用ASP.NET MVC和javascript
当使用ASP.NET MVC和Gijgo Tree View JQuery插件从oracle数据库获取数据时,它在树状视图结构中显示“未定义”,树状视图控件可以在可扩展节点树中显示分层(或嵌套或递归)数据集合。。怎么解决这个问题?拜托,有人帮我吗 我正在尝试这个链接它显示;“未定义”;在树状视图中使用ASP.NET MVC和javascript,javascript,jquery,asp.net-mvc-4,Javascript,Jquery,Asp.net Mvc 4,当使用ASP.NET MVC和Gijgo Tree View JQuery插件从oracle数据库获取数据时,它在树状视图结构中显示“未定义”,树状视图控件可以在可扩展节点树中显示分层(或嵌套或递归)数据集合。。怎么解决这个问题?拜托,有人帮我吗 我正在尝试这个链接 @节脚本{ @Scripts.Render(“~/bundles/Scripts/jqueryval”) //“层次结构/GetHierarchy” $(文档).ready(函数(){ var Usertree=“”; var-
@节脚本{
@Scripts.Render(“~/bundles/Scripts/jqueryval”)
//“层次结构/GetHierarchy”
$(文档).ready(函数(){
var Usertree=“”;
var-tree=“”;
$.ajax({
键入:“get”,
数据类型:“json”,
cache:false,
url:“/Hierarchy/GetHierarchy”,
成功:函数(记录、文本状态、jqXHR){
tree=$('#tree')。tree({
primaryKey:'Id',
数据源:记录,
dragAndDrop:没错,
复选框:正确,
图标库:“glyphicons”,
//uiLibrary:“引导”
});
Usertree=$('#Usertree').tree({
primaryKey:'ID',
数据源:记录,
dragAndDrop:false,
复选框:正确,
图标库:“glyphicons”,
//uiLibrary:“引导”
});
tree.on('nodeDrop',函数(e,ID,PID){
currentNode=ID?tree.getDataById(ID):{};
console.log(“当前节点=“+currentNode”);
parentNode=PID?tree.getDataById(PID):{};
console.log(“父节点=“+parentNode”);
if(currentNode.PID==null&&parentNode.PID==null){
警报(“父节点不可拖放..!!”;
返回false;
}
//console.log(parent.HierarchyLevel);
var params={id:id,parentId:PID};
$.ajax({
类型:“POST”,
url:“/Hierarchy/ChangeNodePosition”,
数据:params,
数据类型:“json”,
成功:功能(数据){
$.ajax({
键入:“获取”,
url:“/Hierarchy/GetHierarchy”,
数据类型:“json”,
成功:功能(记录){
destroy();
Usertree=$('#Usertree').tree({
primaryKey:'ID',
数据源:记录,
dragAndDrop:false,
复选框:正确,
图标库:“glyphicons”,
//uiLibrary:“引导”
});
}
});
}
});
});
$('btnGetValue')。单击(函数(e){
var result=Usertree.getCheckedNodes();
如果(结果=“”){alert(“请选择节点..!!”)}
否则{
警报(“所选节点id为=“+result.join());
}
});
//删除节点
$(“#btnDeleteNode”)。单击(函数(e){
e、 预防默认值();
var result=tree.getCheckedNodes();
如果(结果!=“”){
$.ajax({
类型:“POST”,
url:“/Hierarchy/DeleteNode”,
数据:{values:result.toString()},
数据类型:“json”,
成功:功能(数据){
警报(“已成功删除”);
window.location.reload();
},
错误:函数(jqXHR、textStatus、errorshown){
警报(“错误-”+错误抛出);
},
});
}
否则{
警报(“请选择要删除的节点..!!”;
}
});
},
错误:函数(jqXHR、textStatus、errorshown){
警报(“错误-”+错误抛出);
}
});
//显示模型弹出窗口以在树中添加新节点
$('#btnpopoVeradNode')。单击(函数(e){
e、 预防默认值();
$(“modalAddNode”).modal(“show”);
});
//从弹出窗口保存数据
$(文档)。在(“单击”,“保存节点”,函数(事件){
event.preventDefault();
$.validator.unobtrusive.parse($(“#formaddNode”);
$(“#formaddNode”).validate();
if($('#formaddNode').valid(){
var formdata=$('#formaddNode').serialize();
//警报(formdata);
$.ajax({
类型:“POST”,
url:“/Hierarchy/AddNewNode”,
@section Scripts {
@Scripts.Render("~/bundles/Scripts/jqueryval") <script src="~/Scripts/jquery.validate.min.js"></script> <script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
<script src="@Url.Content("~/Scripts/conditional-validation.js")" type="text/javascript"></script>
<script src="~/Scripts/Gijgo/gijgo.js"></script>
<link href="http://code.gijgo.com/1.3.0/css/gijgo.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
//'Hierarchy/GetHierarchy'
$(document).ready(function () {
var Usertree = "";
var tree = "";
$.ajax({
type: 'get',
dataType: 'json',
cache: false,
url: '/Hierarchy/GetHierarchy',
success: function (records, textStatus, jqXHR) {
tree = $('#tree').tree({
primaryKey: 'Id',
dataSource: records,
dragAndDrop: true,
checkboxes: true,
iconsLibrary: 'glyphicons',
//uiLibrary: 'bootstrap'
});
Usertree = $('#Usertree').tree({
primaryKey: 'ID',
dataSource: records,
dragAndDrop: false,
checkboxes: true,
iconsLibrary: 'glyphicons',
//uiLibrary: 'bootstrap'
});
tree.on('nodeDrop', function (e, ID, PID) {
currentNode = ID ? tree.getDataById(Id) : {};
console.log("current Node = " + currentNode);
parentNode = PID ? tree.getDataById(PID) : {};
console.log("parent Node = " + parentNode);
if (currentNode.PID === null && parentNode.PID === null) {
alert("Parent node is not droppable..!!");
return false;
}
// console.log(parent.HierarchyLevel);
var params = { id: ID, parentId: PID };
$.ajax({
type: "POST",
url: "/Hierarchy/ChangeNodePosition",
data: params,
dataType: "json",
success: function (data) {
$.ajax({
type: "Get",
url: "/Hierarchy/GetHierarchy",
dataType: "json",
success: function (records) {
Usertree.destroy();
Usertree = $('#Usertree').tree({
primaryKey: 'ID',
dataSource: records,
dragAndDrop: false,
checkboxes: true,
iconsLibrary: 'glyphicons',
//uiLibrary: 'bootstrap'
});
}
});
}
});
});
$('#btnGetValue').click(function (e) {
var result = Usertree.getCheckedNodes();
if (result == "") { alert("Please Select Node..!!") }
else {
alert("Selected Node id is= " + result.join());
}
});
//delete node
$('#btnDeleteNode').click(function (e) {
e.preventDefault();
var result = tree.getCheckedNodes();
if (result != "") {
$.ajax({
type: "POST",
url: "/Hierarchy/DeleteNode",
data: { values: result.toString() },
dataType: "json",
success: function (data) {
alert("Deleted successfully ");
window.location.reload();
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Error - ' + errorThrown);
},
});
}
else {
alert("Please select Node to delete..!!");
}
});
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Error - ' + errorThrown);
}
});
// show model popup to add new node in Tree
$('#btnpopoverAddNode').click(function (e) {
e.preventDefault();
$("#modalAddNode").modal("show");
});
//Save data from PopUp
$(document).on("click", "#savenode", function (event) {
event.preventDefault();
$.validator.unobtrusive.parse($('#formaddNode'));
$('#formaddNode').validate();
if ($('#formaddNode').valid()) {
var formdata = $('#formaddNode').serialize();
// alert(formdata);
$.ajax({
type: "POST",
url: "/Hierarchy/AddNewNode",
dataType: "json",
data: formdata,
success: function (response) {
// $("#modalAddNode").modal("hide");
window.location.reload();
},
error: function (response) {
alert('Exception found');
// $("#modalAddNode").modal("hide");
window.location.reload();
},
complete: function () {
// $('.ajax-loader').css("visibility", "hidden");
}
});
}
});
//Close PopUp
$(document).on("click", "#closePopup", function (e) {
e.preventDefault();
$("#modalAddNode").modal("hide");
});
$('.rbtnnodetype').click(function (e) {
if ($(this).val() == "Pn") {
$('.petenddiv').attr("class", "petenddiv hidden");
$("#ParentName").val("");
}
else {
$('.petenddiv').attr("class", "petenddiv");
}
});
});
</script>
}