mbraak / jqTree

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

Make node not draggable based on json data #20

Closed asacarter closed 12 years ago

asacarter commented 12 years ago

Hi

First of all, thanks for making an awesome plugin :)

Is it possible to make to make a node not draggable based on a certain data passed in the json data.

For example:

{ "label":"Home Page", "id":"6", "parent_page_id":"0", "fixed":"1" }, { "label":"Another Page", "id":"7", "parent_page_id":"0", "fixed":"0", ........

If fixed is 1 then make the node not movebable/draggable.

If this is not currently supported, in a future release you could allow css classes to be passed from the json and injected into the html along with .title?

Regards

Asa

mbraak commented 12 years ago

You can use the oncanmove option:

$('#tree1').tree({
  data: data,
  dragAndDrop: true,
  onCanMove: function(node) {
    return (node.fixed != "1");
  }
});

Also see http://mbraak.github.com/jqTree/#tree-options-oncanmove.

You can use the onCreateLi option to inject html (and css classes). See http://mbraak.github.com/jqTree/#tree-options-oncreateli.

asacarter commented 12 years ago

Thanks for that :)