Using CI and jsTree to build a tree control |
[eluser]Nicholai[/eluser]
In this thread I wanted to create a nested list with checkboxes for saving compatibility information to a database. There wasn't much complete stuff out there, so hopefully this helps someone. First, you need this XML helper and jsTree. I gave up on the nested list approach after jsTree didn't play nicely with it, though it can easily convert an XML file to a tree. While the naming conventions for jsTree are pretty strict and the documentation a little lacking, it gives a very nice result. Here's the controller: Code: function index()
[eluser]Nicholai[/eluser]
And here's the JavaScript code for the tree, using the checkbox theme. In the view, I include all the necessary files and this function loads the tree into a DIV with id "tree". Checked items are written to a hidden input called "compat_list" that can be submitted with the form. I hope this helps someone. If you have a more elegant way of achieving this with less code, I'd be very interested to see how an experienced programmer would approach it. Code: function load_admin_tree()
[eluser]Unknown[/eluser]
someone can send the files of the view? please!!!!!! |
Welcome Guest, Not a member yet? Register Sign In |