Hi,
I have defined a treeView and I am populating it with data from ajax call. In the same ajax call, I am getting datasource to the treeview (result.myNodes), and ids to check nodes in the treeview (result.idsNodesToCheck). When I check content of result.idsNodesToCheck, I can see that it has numbers that belongs to the treeView nodes ids. I am using the next code but it is not checking the nodes, don´t know what I am doing wrong. I will appreciate your help.
<div id="myTreeView"></div>
<script>
$.ajax({
url: "/backoffice/GetNodes/?id=" + $("#IdPerfil").val(),
type: "GET",
cache: false,
success: function (result) {
if (result.succeed) {
$("#myTreeView").ejTreeView({
fields: {
dataSource: result.myNodes,
id: "IdFuncionesModulo",
parentId: "IdFuncionPadre",
text: "DescripcionFuncion"
},
showCheckbox: true,
allowMultiSelection: true,
});
var treeObj = $("#MyTreeView").ejTreeView('instance');
for (var i = 0; i < result.idsNodesToCheck.length; i++) {
treeObj.checkNode($("#" + i.toString()));
}
treeObj.refresh();
}
else {
NotyAviso('error', result.msg, false, true, false, true);
}
},
error: function (jqXHR, textStatus, error) {
NotyAviso('error', error, false, true, false, true);
}
});
</script>