DataManager for resources

Hi,

I want to load the resources via REST API and I'm having some trouble.
I'm using ej.DataManager to load it in this way: 

this.resourcesManager = new ej.DataManager({ url: "http://xxx", crossDomain: true});
var query = new ej.Query();
var dataObj = this.resourcesManager.executeQuery(query); //Request the webService
dataObj.done(function (e) {
this.resourceList = e.result;
});

Data sent looks like this.


And in my gantt component the Mappings are like this:

[resources]="resourceList"
resourceNameMapping="reference"
resourceIdMapping="wrk_id"

The request goes fine and this.resourceList gets the info, but the gantt loads nothing. It seems like the gantt had already mapped the resources info before the request is finished and then it finds nothing. Any idea?

Thanks.

7 Replies

JD Jayakumar Duraisamy Syncfusion Team July 9, 2018 12:49 PM UTC

Hi Oscar, 
We have analyzed the reported problem and it is due to ej.DataManager asynchronous call execution. To overcome this problem, we have to set the DataManager  property called async as false. 
Please refer following code snippet, 
export class AppComponent { 
  constructor() { 
     this.resourceList = this.getResources(); 
} 
getResources(){ 
    var resources = []; 
    var dataManager = new ej.DataManager({ 
      url: "http://xxxxx", 
      async: false,   
      crossDoamin: true      
    }); 
    dataManager.executeQuery(new ej.Query()).done(function(e){ 
      resources = e.resources; 
    }); 
  return resources;     
  }  
 
} 
 
 
Please let us know, if you require any other assistance on this. 
Regards, 
Jayakumar D 



OB oscar bartolome July 10, 2018 09:18 AM UTC

Ok, that solves the problem, thanks.

But now I'm facing another one. As you see in the previous code, the resource name mapping is a field called 'reference'. My tasks have a field called 'reference' too. This is causing trouble, now in Resources view mode, it loads the 'reference' field of the tasks as if it was a workcenter, and the event 'queryTaskbarInfo' is called for every resource as if they were tasks. Any idea why is happening this?

Thanks.


OB oscar bartolome July 10, 2018 11:07 AM UTC

I have realized that the problem is that when loading the resources using ejDatamanager, then the tasks are not binded with their resources. They appear as Unassigned tasks.
Any idea?

Thanks 


PE Punniyamoorthi Elangovan Syncfusion Team July 11, 2018 01:07 PM UTC

Hi Oscar, 
We have analyzed your reported issue, but we are unable to reproduce the reported issue in our end. We have prepared the sample for your reference with details you have shared with us, in this sample we had assign the resources by using ejDataManager support then the tasks are rendered properly based upon the resources in Gantt. 
Please find the sample link below 
Please let us know if you require further assistance on this. 
Regards, 
Punniyamoorthi 
 



OB oscar bartolome July 11, 2018 01:49 PM UTC

Hi,

can you try an example where the data and the resources are both loaded using ejDatamanager instances? I'm trying it, but the tasks aren't being rendered.

Thanks.


OB oscar bartolome July 12, 2018 08:06 AM UTC

Hi,

I've solved this issuse. The tasks were not binding to the resources with the habitual code. In the tasks, I add the property to bind the resource in the habitual way: Resources:[2], but this doesn't work. Adding the property this way: Resources: "2" does work. Take a look at it.

Thanks.


PE Punniyamoorthi Elangovan Syncfusion Team July 12, 2018 01:29 PM UTC

Hi Oscar, 
In Gantt, if we set the value for resource ID in resource collection in string data type, then we will need to set the resource ID value as the string in the data source. And if we need to assign multiple resources for a task, then we can set the resource ID values to the task as array of string. In your application, you had set the resource ID(wrk_id) as a string value but you have assigned it as an integer value to the data source previously and due to this the records were not rendered properly in your application. 
We have prepared the sample for your reference, please find the sample link below 
Regards, 
Punniyamoorthi 
 


Loader.
Up arrow icon