ezraroi / ngJsTree

Angular Directive for the famous JS Tree
http://ezraroi.github.io/ngJsTree/
MIT License
270 stars 101 forks source link

Can I use custom data format? #106

Closed anatoly314 closed 7 years ago

anatoly314 commented 7 years ago

As I understand from jsTree tutorial native plugin does support this feature. I just provide callback function which called on each node and I can format it as desired. Can I do same with angularized plugin?

For example my data node is following:

       {
            "groupId": 21,
            "parentGroupId": 0,
            "groupName": "Network",
            "ownerId": "123456"
        }

So, instead of id I want to use groupId, instead of parent I want to use parentGroupId and instead of text I want to use groupName.

Thank you in advance.

ezraroi commented 7 years ago

I am not aware of this plugin... just try :)

smohammedyasin commented 7 years ago

you can use core.data jsTree config.

$('#your-tree').jstree({
    core : {
        data : function (node, cb) {
            $.ajax({ url : ... }).done(function (data) {
                cb([{ "id" : data.id, "text" : data.name }])
            });
        }, ...

similar question posted here

anatoly314 commented 7 years ago

@smohammedyasin , thank you. Will try it next time or perhaps it will be useful for someone else. I just make function which transform all my object accordingly to jsTree requirement every time when I need, works perfect.