mbraak / jqTree

Tree widget for jQuery
https://mbraak.github.io/jqTree/
Apache License 2.0
1.02k stars 177 forks source link

Load on demand, how to pass my self parameter? #237

Closed rankun203 closed 10 years ago

rankun203 commented 10 years ago

Hi, everyone, Is there a way to pass a parameter with Load on demand?

I'm working on a project, and I need to retrieve some books, units, sections, articles, from server. books has units, units has sections or articles, sections has other articles.

So, first I will get all books, and shows it on the tree, once user click a book, then get all units of a book. Click a unit, we get the articles and sections.

My problem is I need to pass a parameter named depth to detect if the request node is a Book or Unit on server, cause the id is represent different means with Books and Units, then call different service to get its subnodes.

Thanks. Any idea? or maybe I need redesign the Server side Controller?

mbraak commented 10 years ago

Hello Rankun,

It is possible to change to url for load-on-demand depending on the node. So, you can for example change the url for loading a book.

You can use the dataUrl option for this. See issue 114 and issue 80 for an example.

I can also add an example if you want.

Greetings, Marco

rankun203 commented 10 years ago

Sorry mbraak, I was missed the #80 and #114 before I post this issue, I will check them, Thank you so much.

rankun203 commented 10 years ago

Hi Marco,

I'm down, That's works for me,

I have noticed that you don't add Document yet of dataUrl function in current version document http://mbraak.github.io/jqTree/#tree-options-data-url, Maybe it should be there.

Thank you again, for your awesome job. Kun