eu81273 / angular.treeview

AngularJS based Treeview (no jQuery)
MIT License
405 stars 223 forks source link

How to add AJAX call for each node to fetch data? #12

Open Karttin opened 10 years ago

Karttin commented 10 years ago

Hi,

Your tree view is simple and clean. Is there any way i can add nodes based on a AJAX/Get call for each node?

Kind Regards Kay

dehru commented 10 years ago

I'm interested in this too since I don't have all the tree data at first.

nichtich commented 10 years ago

me2

Dorianux commented 10 years ago

+1

adelima83 commented 9 years ago

I am currently working on this. I figured out a way of doing it.

Essentially, on selected node click, scope.functionname.

Have the function in the controller, use your factory to load data and then inject data into the selected node. Make sure to pass the node to the function.

When i am fully done with the treeview project i am working on i will post a solution for lots of scenarios.

amarpreethora commented 9 years ago

Hi I know it's too late to answer this question but recently I applied one solution to achieve what you are asking for?

In your "selectedNode" method you can call one method written in the controller like -

scope.selectNodeHead = scope.selectNodeHead || function(selectedNode) { if (!selectedNode.collapsed){ scope.populateSample(selectedNode); }else{ selectedNode.collapsed = !selectedNode.collapsed; } };

and Inside your controller - $scope.populateSample= function(selectedNode){ var Id= selectedNode.idKey; var req = { method: 'GET', url: "case/" + Id+ "/sample", headers: { "Content-Type" : "application/json; charset=UTF-8" }
}; $http(req).success(function(jsondata){ ...... }

Hope this helps.. :-)

the7erm commented 8 years ago

Thanks for the example @amarpreethora https://guides.github.com/features/mastering-markdown/#examples

Hi I know it's too late to answer this question but recently I applied one solution to achieve what you are asking for?

In your "selectedNode" method you can call one method written in the controller like -

scope.selectNodeHead = scope.selectNodeHead || function(selectedNode) {
    if (!selectedNode.collapsed){
        scope.populateSample(selectedNode);
    }else{
        selectedNode.collapsed = !selectedNode.collapsed;
    }
};

and Inside your controller -

$scope.populateSample= function(selectedNode){
    var Id= selectedNode.idKey;
    var req = {
        method: 'GET',
        url: "case/" + Id+ "/sample",
        headers: {
            "Content-Type" : "application/json; charset=UTF-8" 
        }
    };
    $http(req).success(function(jsondata){
    ......
    }

Hope this helps.. :-)

sankarmahadevan commented 6 years ago

I need to call a function in controller when a node is selected. Based on the selected node value, i need to call server api for results. Is there any way to accomplish this? Also I need to show in which level current selected node in breadcrumb. 2017-10-25_194201

Please anyone help me.