I'm trying to use JsTree, with Ajax. The first image shows the initial state of JsTree without the Ajax call.
The user click on the first node, and selects all items, according second image.
Before post values, I call a function to grab all the selected items in JsTree. Result of function, it is third image.
If I call the data by Ajax, the result of the JsTree conforms to the image four
Question
What should I set / configure, so the Ajax return is the same when the user clicks on the nodes. After the return of Ajax, there is no selected node.
My JsTree Config
$('#tree').jstree({
'plugins': ["checkbox"],
'core': {
'data': {
'url': '/Ajax/AcessoFuncao/',
'data': function (node) {
return { 'acessoperfil': $("#AcessoPerfilID").val() };
}
}
}
});
My Code Before Post
function BeforePost()
{
document.getElementById("items").value = $("#tree").jstree(true).get_checked().join(',');
alert(document.getElementById("items").value);
}
My Json Data
[
{
"id":"1",
"parent":"#",
"text":"AcessoFuncao",
"icon":"fa fa-tags",
"state":{
"opened":false,
"disabled":false,
"selected":true
},
"li_attr":null,
"a_attr":{
"id":null,
"class":"no_checkbox"
}
},
{
"id":"1_1",
"parent":"1",
"text":"Listar",
"icon":"fa fa-list",
"state":{
"opened":false,
"disabled":false,
"selected":true
},
"li_attr":null,
"a_attr":{
"id":null,
"class":"jstree-checked jstree-clicked"
}
},
{
"id":"1_4",
"parent":"1",
"text":"Inserir",
"icon":"fa fa-plus",
"state":{
"opened":false,
"disabled":false,
"selected":true
},
"li_attr":null,
"a_attr":{
"id":null,
"class":"jstree-checked jstree-clicked"
}
},
{
"id":"1_2",
"parent":"1",
"text":"Visualizar",
"icon":"fa fa-eye",
"state":{
"opened":false,
"disabled":false,
"selected":true
},
"li_attr":null,
"a_attr":{
"id":null,
"class":"jstree-checked jstree-clicked"
}
},
{
"id":"1_8",
"parent":"1",
"text":"Alterar",
"icon":"glyphicon glyphicon-edit",
"state":{
"opened":false,
"disabled":false,
"selected":true
},
"li_attr":null,
"a_attr":{
"id":null,
"class":"jstree-checked jstree-clicked"
}
},
{
"id":"1_16",
"parent":"1",
"text":"Excluír",
"icon":"fa fa-trash-o",
"state":{
"opened":false,
"disabled":false,
"selected":false
},
"li_attr":null,
"a_attr":null
}
]