gijgo icon indicating copy to clipboard operation
gijgo copied to clipboard

Lazy Loading not working on WebApi controller

Open andresmachadofernandez opened this issue 5 years ago • 0 comments

Hello guys. I have been trying to set up a tree with lazy loading that fetches the data from an ApiController, and it does not seem to be working. Setting up a method on the ApiController (the method is declared LazyGet(int? parentId)) does not work. I can send a variable trough the datasource url like this:

$('#tree').tree({ primaryKey: 'id', dataSource: 'api/MyController/LazyGet?parentId=' + 5, lazyLoading: true });

This will reach the method on the webApi controller, and the parentId variable will be correctly recieved as 5. However, trying to send the dynamic parentId as you show in your example:

$('#tree').tree({ primaryKey: 'id', dataSource: 'api/MyController/LazyGet', lazyLoading: true });

does not work; the request will never reach the controller, simply prompting a "Not found" alert (this is obviously because my method in the controller is declared with a int? parentId parameter, so it throws a 404 after not matching the parameterless method in the url with the one on the controller).

I have pretty much copy-pasted the code from the example (which I have also downloaded and debugged) and I can say with pretty much certainty that the only difference between my code and yours is the fact that you use a MVC controller, and I use a WebApi one. Is this a known bug? Is the lazy loading feature not supported on WebApi? I ask because, so far, it seems to be the only feature that does not work on WebApi, and it just seemed kinda weird.

Thanks you in advance.

andresmachadofernandez avatar Apr 08 '20 19:04 andresmachadofernandez