My dad mentioned an interesting project to me the other day, posing the challenge of coming up with an interface for examining deep rubrics for grading classes, or businesses, or anything that needs a grade. The idea is that you have a tree of different aspects that go into an overall grade. The interface needs to show this tree breakdown, while showing several controls with each item in the list. In short, the interface needs a Tree Table.
There are a few treetable components out there (Swing, Qt, ASP.NET), but I wanted to do this in jQuery. Because jQuery is the bees knees, and distributing apps purely in the browser is something I’ve been working towards. With that in mind, the design goal is that the application would be a single folder, completely self contained, and run by opening a .html file. Not being one to reinvent the wheel, I took a look at what plugins there were and found treeTable and JQTreeTable. Unfortunately, both are terrible. The HTML needed is horribly, disgustingly unsemantic. treeTable uses class and id attributes of the tr tags, and JQTreeTable has you pass in a map of child to parent ids. BLECH! Having to add an id to every row, and then ask a designer to follow that? NO!
So, I wrote my own. The guiding, number one goal was a semantic markup- the list hierarchy *MUST* be conveyed using a ul/li structure. Beyond that, the plugin should be as configurable as possible, while using as clean a plugin architecture as possible. Since this was my first trip around the jQuery ui block, I found bililite.com’s jQuery UI Widget tutorial an invaluable resource.
<ul id="tree">
<li class="head">
<span class="aspect">Aspect</span><span class="weight">Weight</span><span class="grade">Grade</span><span class="cost"/>Cost</span><span class="value"/>G/$</span>
</li>
<li>
<span>Software Develoment</span><span>70%</span><span></span>
<ul>
<li>
<span>Design</span><span>30%</span><span></span>
<ul>
<li>
<span>Requirements</span><span>33%</span><span>85</span><span>30</span>
</li>
<li>
<span>Mockups</span><span>33%</span><span>90</span><span>5</span>
</li>
<li>
<span>Planning</span><span>33%</span><span>60</span><span>50</span>
</li>
</ul>
</li>
<li>
<span>Development</span><span>50%</span><span>80</span><span>70</span>
</li>
<li>
<span>QA</span><span>20%</span><span>50</span><span>100</span>
</li>
</ul>
</li>
<li>
<span>Marketing</span><span>30%</span><span></span>
<ul>
<li>
<span>Online</span><span>45%</span><span>85</span><span>10</span>
</li>
<li>
<span>Print</span><span>35%</span><span>60</span><span>25</span>
</li>
<li>
<span>Radio</span><span>25%</span><span>75</span><span>15</span>
</li>
</ul>
</li>
</ul>
Pretty minimal, isn’t it? The API is exposed through triggers, in a very functional way. Extending is easy, as show in the full demo. The code is available at http://code.google.com/p/jmtt/ under an lgpl license. For bonus points, the columns are resizable.
14 Comments
I am unable to download the source and demo samples. Can you please help me with that?
Venky, you didn’t leave an your email address, so I can’t get ahold of you directly. The code is hosted on Google Code, http://code.google.com/p/jmtt/source/checkout is a link to the source there. Are there any other issues you’ve had or are having?
David,
I am unable to checkout the source code from google repo. http://code.google.com/p/jmtt/source/checkout.
Can you please email me(venkymr@gmail.com) the source code package with the demo also to my email?. I will really appreciate your help
Venky
David,
Never mind. I installed http://tortoisehg.bitbucket.org/ and used the tool to checkout as given by you in the google checkout page
Regards
Venky
Do you have any plans to introduce drag and drop feature for the tree nodes?. Please let me know
I’d like to add a few features, include both row and column reordering through drag and drop, column sorting, etc. Unfortunately, I have not had time. If you’d like to take a shot at it, I’d love to merge any code you have into the project core.
delete node is working fine and we can see the result during the SAVE. But it is not working for level1 node’s. Can you please let me know how to fix it
I’m not sure quite what behavior you’re describing. Could you submit a qunit[1] test case to the issue tracker[2]?
[1] http://docs.jquery.com/QUnit
[2] http://code.google.com/p/jmtt/issues/entry
defect raised
David,
More bugs. I will raise some defect again. Please help me in this. I progressed so far in my customization and now got hit with these bugs
Venky
David,
Let me know if you can fix that quickly. Otherwise my whole effort will go waste and I have to switch to some other treetable component from the beginning
Venky
David,
The simple summary of the bus is this
1) delete the nodes/add siblings for the level1 nodes
2) save is not reflecting the current state of the tree
Venky,
Thank you so much for filing those reports, it’s really cool to know someone’s using this! I have fixed the underlying issue causing both of those.
If you can, would you link to the project you’re using this for when you’ve finished? I’d love to see what JMTT’s being used for.
David,
Thank you so much for quickly fixing this. It is my pleasure to work on your component because it is so easy and well documented with examples. I never saw such a good extensible component with document and example especially for this tree table component.
I am sure this component will be used by LARGE numbers in coming days as I do not see any GOOD Alter Natives for this complex component(yeah, it is simple for you of course).
Thank you so much once again and definitely I will promote your component through my blogs and also in reviews.
Regards
Venky