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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Load variable with result form DataManager

Thread ID:

Created:

Updated:

Platform:

Replies:

146311 Jul 30,2019 09:41 PM UTC Aug 1,2019 12:20 PM UTC JavaScript - EJ 2 3
loading
Tags: DataManager
Stephan Schrade
Asked On July 30, 2019 09:41 PM UTC

Hi support,
I'm getting a little frustrated with the datamanager.

From your examples I think the following code should work:
var dataext = new ej.data.DataManager({
url: 'http://localhost/rubw2/basic/web/nav/navleft',
adaptor: new ej.data.WebApiAdaptor()
}).executeQuery(new ej.data.Query()).then((e) => {
datamanager = e.result;
});

But the variable datamanger is empty.

Result of localhost/rubw2/basic/web/nav/navleft is:
{"Items":[{"nodeId":"1","nodeText":"Home","url":"/home"},{"nodeId":"2","nodeText":"Athletes","url":"/athlets"}],"Count":1}

which does generate a nice tree view when I use the data manger without query and set the tree view property dataSource to the datamanger (variable dataext)

Regards,
Stephan










Thavasianand Sankaranarayanan [Syncfusion]
Replied On July 31, 2019 08:56 AM UTC

Hi Stephan, 

Thanks for contacting Syncfusion support. 

If you are using data manager for data binding then there is no necessary to perform the excuteQuery it automatically execute the query and bind the data to the component. If you are using the below way then it work as remote data binding for every actions(like paging, sorting) we have send the query and you need to handle it in server side. 

// if you are binding(dataext) like this then it considered as remote data  
var dataext = new ej.data.DataManager({ 
        url: '/api/Orders/', 
        adaptor: new ej.data.WebApiAdaptor() 
    }) 

<script> 
    var datamanager; 
    var dataext = new ej.data.DataManager({ 
        url: '/api/Orders/', 
        adaptor: new ej.data.WebApiAdaptor() 
    }).executeQuery(new ej.data.Query()).then((e) => { 
        datamanager = e.result; // if you bind datamanager for component then it considered as local data and its done the actions such as sort etc., in client side. 
        console.log(datamanager) 
    }); 
</script> 

We have checked with our end and we are able to get the datamanager (e.result did not empty). Please share more information regarding your requirement that will helpful for us to validate further at our end(also share the sample or code example). Also refer the below help documentation link for more information. 


Regards, 
Thavasianand S. 


Stephan Schrade
Replied On July 31, 2019 07:31 PM UTC

Thank you for your quick answer.

I understand now, that
as e.result is generated in the anonymous function, the scope is local.
So I cant't get. the data to the "outside".
How can I achieve this? (I know this is more a javascript question than syncfusion related)

Or is there another way to get the pure received data (json reply) trough the DataManger without using a query?
Or do I have to do this without DataManager as all?

TIA
Stephan

Dhivya Rajendran [Syncfusion]
Replied On August 1, 2019 12:20 PM UTC

Hi Stephan, 

Thanks for your update. 

You can declare global variable and assign the result(JSON) to the variable so that you can get the value outside of the scope. Please share more information about your requirement and share the component details whether did you used syncfusion component(like grid, treeview etc.,) or any other custom component.  
  
<script> 
    var datamanager; 
    var dataext = new ej.data.DataManager({ 
        url: '/api/Orders/', 
        adaptor: new ej.data.WebApiAdaptor() 
    }).executeQuery(new ej.data.Query()).then((e) => { 
        datamanager = e.result; // if you bind datamanager for component then it considered as local data and its done the actions such as sort etc., in client side. 
        console.log(datamanager) 
    }); 
</script> 
 
// you can bind datamanager(it contain the JSON result) to the component 

Note : If you don’t want to use data manager then you can make your own AJAX request and get the data from server. 

Regards, 
R.Dhivya  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon