We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

What tag for the server response and what adaptor to use?

Hello,

how do I use the the remote data source properly?
If I use your example data (xml) from
https://js.syncfusion.com/demos/ejServices/Wcf/Northwind.svc

it works. But I have a json source which returns sth like this:

{"id":'root',"parent_id":0,"name":"Root","subChild":[
{"id":1,"parent_id":0,"name":"Test Folder","subChild":[
{"id":2,"parent_id":1,"name":"Child 1"},
{"id":3,"parent_id":1,"name":"Child 2","subChild":[
{"id":4,"parent_id":3,"name":"Child 3"}
]
}
]
},
{"id":5,"parent_id":0,"name":"User 2 Folder 1"},
{"id":6,"parent_id":0,"name":"User 2 Folder 2"}]
}

Do I have to wrap the response in a specific tag, if so what tag? Which Adaptor do I use? I thought that I should use the UrlAdaptor?
It should only be a single request on initialization. Everything else should be handled on the client side.


I wasn't able to find any helpful information in the docs.

Thanks in advance



3 Replies

CI Christopher Issac Sunder K Syncfusion Team April 1, 2019 12:49 PM UTC

Hi Christopher, 

Greetings from Syncfusion!!! 

Your requirement can be achieved by using EJ2 DataManger. We have utilized the “mounted” life cycle event to bind the data from the service. 

mounted() { 
    this.getData(); 
}, 
methods: { 
    async getData() { 
        const data = await new DataManager({ 
            url: SERVICE_URL 
        }).executeQuery(new Query()); 
        this.fields = { 
            id: "id", 
            text: "name", 
            child: "subChild", 
            dataSource: data.result.defaultData 
        }; 
    } 
} 


Please let us know if you have any concerns. 

Thanks, 
Christo 



CH Chris April 1, 2019 02:04 PM UTC

Hello Christopher Issac Sunder K,

thanks for the code, was able to solve the problem! :)

Best


CI Christopher Issac Sunder K Syncfusion Team April 2, 2019 11:34 AM UTC

Hi Christopher, 

We are glad to hear that the issue has been resolved at your end. Please let us know if you require any further assistance.  

Thanks,
Christo 


Loader.
Live Chat Icon For mobile
Up arrow icon