Search code examples
javascriptjqueryknockout.jstreetable

Using jQuery Plugin Treetable with Knockoutjs


I am using knockout.js and want to use the jquery plugin treetable. But I don't get it to work. Has someone build something similar using knockout.js and probably with this plugin?

I was trying to integrate it using a bindingHandler:

<table data-bind="treetable: tasks, treeOptions: { initialState: 'expanded' } ">
  <tbody data-bind="foreach: tasks">
    <tr data-bind="attr: { 'data-tt-id': id, 'data-tt-parent-id': parentId }">
      <td data-bind="text: title"></td>
    </tr>
  </tbody>
</table>

See my full code here: http://jsfiddle.net/qhgfx0ff/1/

Thanks for any hint or help!

Cheers, TeeJay


Solution

  • We cannot directly use thirdparty plugins in knockout. We need to create a custom binding for them.

    Look at the section

    Custom binding handlers

    in the link here which has integrating third party widgets in knockout. You can use similar kind of logic here