2
I’m using the plugin jsTree, trying to make you seek the information by AJAX.
In the server side I have four tables on the bench, each one a tree level.
Tabela1
-Tabela2
--Tabela3
---Tabela4
Making the plugin fetch the first level was easy:
$("#tree").jstree({
core: {
data: {
url: "/tabela1.json"
}
}
});
But I’m not getting the syntax right to make you search for the other level, at the click of the user.
The two attempts below did not work:
$("#tree").jstree({
core: {
data: {
url: "/tabela1.json",
data: "/tabela2.json"
}
}
});
$("#tree").jstree({
core: {
data: {
url: "/tabela1",
data: {
url: "/tabela2.json"
}
}
}
});
How are these JSON organized? Sometimes you need a function if you want to control the sublevels. jsTree is relatively simple to use, but I’m not getting what you’re trying to do. It has how to show JSON structures and how you want to organize them?
– Bacco
@Bacco It is the first time I use this plugin. I have hidden the names of the tables because they do not suit the problem. But Table1 has many Tables2, which has many Tables3, which has many Tables4. To save bandwidth, the idea is to confirm the user’s click.
– user7261
@Bacco No server side I have routes that return the correct format jsTree asks for, i.e.,
{'id': 1, 'text': 'Texto'}
and accept filter by query string.– user7261
I think it is the case that you create your load function then, which is the date parameter of the http://www.jstree.com/docs/json/ nodes at the bottom of the page.
– Bacco
@Bacco In this case I have to use
$.getJSON
and pass the return to the functioncb
?– user7261
@user7261 I am studying to make one, when I finish put my code for you.
– Marconi
@user7261 follows my logic posted here on Stack. http://answall.com/questions/43477/montar-%C3%A1rvore-jstree/44949#44949
– Marconi