Multiple Resources dont show in the tasks


#1

I would like to help me solve this problem that is being presented to me, I have read and searched the forum and I have not found any solution

I present my scenario

Ganttconector.php

<?php

    include (’…/config.php’);

    include (’…/…/codebase/gantt_connector.php’);

    

$res= new PDO($mysql_server,$mysql_user,$mysql_pass); 

$project_id = 1;

$gantt = new JSONGanttConnector($res, “PDO”);

$links = new JSONGanttLinksConnector($res);

$stage  = new JSONOptionsConnector ($res);

$stage->render_table(“tbl_stage”, “idstage”, “idstage(value),stage(label)”);

$resource  = new JSONOptionsConnector ($res);

$resource->render_table(“gantt_resources”, “resource_id”, “resource_id(value),resource(label),unit,default_value,type”);

$gantt->mix(“open”, 1);

$links->filter(“projectId”, $project_id);

$links->render_table(“gantt_links”, “id”, “source,target,type,projectId”);

$gantt->set_options(“links”, $links);

$gantt->enable_log(“gantt_log.log”,true);

$gantt->filter(“projectId”, $project_id);

$gantt->set_options(“resource_Data”, $resource);

$gantt->render_table(“gantt_tasks”,“id”,“start_date,duration,text,type,progress,parent,resources_ids,projectId”,"");

?>

Result Log OK

Log started, 26/10/2020 01:34:37

====================================

DataProcessor object initialized

4_id => 4

4_start_date => 2020-10-23 00:00

4_duration => 1

4_text => New task

4_type => 

4_progress => 0

4_parent => 0

4_resources_ids => [{“resource_id”:“1”,“value”:“8”},{“resource_id”:“2”,“value”:“8”}]

4_projectId => 1

4_open => 1

4_end_date => 2020-10-24 00:00

4_!nativeeditor_status => updated

ids => 4

Row data [4]

id => 4

start_date => 2020-10-23 00:00

duration => 1

text => New task

type => 

progress => 0

parent => 0

resources_ids => [{“resource_id”:“1”,“value”:“8”},{“resource_id”:“2”,“value”:“8”}]

projectId => 1

open => 1

end_date => 2020-10-24 00:00

!nativeeditor_status => updated

UPDATE gantt_tasks SET start_date=‘2020-10-23 00:00’,duration=‘1’,text=‘New task’,type=’’,progress=‘0’,parent=‘0’,resources_ids=’[{“resource_id”:“1”,“value”:“8”},{“resource_id”:“2”,“value”:“8”}]’,projectId=‘1’ WHERE id=‘4’

I show them the file I’m working on

index.html (10.2 KB)


#2

Hello Juan,
It seems as if the resource data is not loaded:
http://snippet.dhtmlx.com/5/95e8e7068
If you uncomment the following line in the snippet, you will see the loaded data:

//gantt.serverList("resource_data")

You need to check what values you have when you apply the following command in the web console:

gantt.serverList("resource_Data")

#3

Thanks for the support, but note that by doing what you indicate, the data appears, but when I edit it, the owners do not appear, as I indicate in the image and it puts it as unassigned

Multiple_Resources_Unassigned

If you could support me since I have several weeks trying to figure this out.


#4

Hello Juan,
Sorry, I forgot to add the onParse event to the resource store. Here is the updated snippet:
http://snippet.dhtmlx.com/5/0cd0283a5


#5

Hello Ramil, thank you very much, it is already working properly, in the example presented, but I have the following problem, when I bring the collections resource_data, it appears with quotes in each of the values, and presenting the same scenario in the example it stops place the values ​​again, so that we could make the when calling the render_table this brings it up presenting the values ​​without quotes, as illustrated in the images mentioned here.

Configuration Gantt Connector

Awaiting your comments, I thank you very much for your infinite support.

I salute you


#6

Attach Gannt Connector


#7

Hello Juan,
If the resource data has the String type for all values, the resources should be displayed in the lightbox:


http://snippet.dhtmlx.com/5/a1ff3c851

Please, reproduce the issue in the snippet and send it to me.


#8

Hello Good afternoon, I thank you for the support provided, in the snippet, that you send me, it works very well, and already placing it in my project, the data is not brought, as the image illustrates

This image shows how the data is brought

Attach gantt_connector.php

<?php

    include (’…/config.php’);

    include (’…/…/codebase/gantt_connector.php’);

    

$res= new PDO($mysql_server,$mysql_user,$mysql_pass); 

$project_id = 1;

$gantt = new JSONGanttConnector($res, “PDO”);

$links = new JSONGanttLinksConnector($res);

$stage  = new JSONOptionsConnector ($res);

$stage->render_table(“tbl_stage”, “idstage”, “idstage(value),stage(label)”);

$resource  = new JSONOptionsConnector ($res);

//$resource->render_table(“v_resourcesleads”, “id”, “text, parent, value”);

$resource->render_table(“gantt_resources”, “id”, “id(value),resource(text),parent”);

$gantt->mix(“open”, 1);

$links->filter(“projectId”, $project_id);

$links->render_table(“gantt_links”, “id”, “source,target,type,projectId”);

$gantt->set_options(“links”, $links);

$gantt->enable_log(“gantt_log.log”,true);

$gantt->filter(“projectId”, $project_id);

$gantt->set_options(“resource_data”, $resource);

$gantt->render_table(“gantt_tasks”,“id”,“start_date,duration,text,type,progress,end_date,resources,projectId,parent”,"");

?>

The File Index.html
index.html (14.6 KB)


#9

Hello Juan,
I added your data from the HTML page, and it seems that you need to change 2 things:

  1. You have a different name for the array with the resource data:
    http://prnt.sc/vfzksm
  2. Before parsing the data from the server list, you need to create it:
    http://prnt.sc/vfzrjp
    Otherwise, Gantt will create an empty server list.

I updated the snippet, so now, your resource data is displayed there:
http://snippet.dhtmlx.com/5/a82c52233


#10

Hi Ramil
Thank you very much for your support, but I don’t know if you won’t explain, but I put the snipper code you sent me as is and it doesn’t work, I’m already worried because I have to give progress on the project and I haven’t been able to solve this issue.

I attach all the documents to see where I am doing something wrong.

The only difference is that when I fetch the resource values, it brings them to me id, text, parent, but it doesn’t show anything.

I’m going to thank you infinitely, for your support

<?php

    include (’…/config.php’);

    include (’…/…/codebase/gantt_connector.php’);

    

$res= new PDO($mysql_server,$mysql_user,$mysql_pass); 

$project_id = 1;

$gantt = new JSONGanttConnector($res, “PDO”);

$links = new JSONGanttLinksConnector($res);

$stage  = new JSONOptionsConnector ($res);

$stage->render_table(“tbl_stage”, “idstage”, “idstage(value),stage(label)”);

$resource  = new JSONOptionsConnector ($res);

//$resource->render_table(“v_resourcesleads”, “id”, “text, parent, value”);

$resource->render_table(“gantt_resources”, “id”, “resource(text),parent,value”);

$gantt->mix(“open”, 1);

$links->filter(“projectId”, $project_id);

$links->render_table(“gantt_links”, “id”, “source,target,type,projectId”);

$gantt->set_options(“links”, $links);

$gantt->enable_log(“gantt_log.log”,true);

$gantt->filter(“projectId”, $project_id);

$gantt->set_options(“resourcedata”, $resource);

$gantt->render_table(“gantt_tasks”,“id”,“start_date,duration,text,type,progress,owner,projectId,parent”,"");

?>

Data:

{ “data”:[{“id”:“1”,“start_date”:“2020-11-09 00:00:00”,“duration”:null,“text”:“Plan, Define, Award”,“type”:“project”,“progress”:null,“owner”:null,“projectId”:“1”,“parent”:null,“open”:1},{“id”:“2”,“start_date”:“2020-11-07 00:00:00”,“duration”:“24”,“text”:“Awarded design cost “,“type”:“task”,“progress”:“0.0795918”,“owner”:”[{“resource_id”:“1”,“value”:“8”},{“resource_id”:“3”,“value”:“8”}]”,“projectId”:“1”,“parent”:“1”,“open”:1},{“id”:“3”,“start_date”:“2020-11-07 00:00:00”,“duration”:“24”,“text”:“Awarded specification with physical property data “,“type”:“task”,“progress”:“0.290476”,“owner”:”[{“resource_id”:3,“value”:0}]”,“projectId”:“1”,“parent”:“1”,“open”:1},{“id”:“4”,“start_date”:“2020-11-17 00:00:00”,“duration”:“7”,“text”:“Prueba 1”,“type”:“task”,“progress”:“0”,“owner”:"[{“resource_id”:5,“value”:0}]",“projectId”:“1”,“parent”:“1”,“open”:1},{“id”:“5”,“start_date”:“2020-11-17 00:00:00”,“duration”:“7”,“text”:“Prueba 2”,“type”:“task”,“progress”:“0”,“owner”:"[{“resource_id”:5,“value”:0}]",“projectId”:“1”,“parent”:“1”,“open”:1},{“id”:“6”,“start_date”:“2020-11-24 00:00:00”,“duration”:“9”,“text”:“Prueba 3”,“type”:“task”,“progress”:“0”,“owner”:"[]",“projectId”:“1”,“parent”:“1”,“open”:1},{“id”:“116”,“start_date”:“2020-11-07 00:00:00”,“duration”:“6”,“text”:“New task”,“type”:“task”,“progress”:“0”,“owner”:"[{“resource_id”:“6”,“value”:“6”},{“resource_id”:“7”,“value”:“8”}]",“projectId”:“1”,“parent”:“0”,“open”:1},{“id”:“117”,“start_date”:“2020-11-07 00:00:00”,“duration”:“1”,“text”:“New task”,“type”:“task”,“progress”:“0”,“owner”:"[]",“projectId”:“1”,“parent”:“116”,“open”:1}], “collections”: {“links”:[{“id”:“1”,“source”:“4”,“target”:“5”,“type”:“1”,“projectId”:“1”},{“id”:“2”,“source”:“5”,“target”:“6”,“type”:“1”,“projectId”:“1”},{“id”:“3”,“source”:“5”,“target”:“6”,“type”:“0”,“projectId”:“1”},{“id”:“4”,“source”:“2”,“target”:“3”,“type”:“1”,“projectId”:“1”},{“id”:“5”,“source”:“2”,“target”:“5”,“type”:“1”,“projectId”:“1”},{“id”:“6”,“source”:“3”,“target”:“4”,“type”:“0”,“projectId”:“1”},{“id”:“7”,“source”:“73”,“target”:“74”,“type”:“1”,“projectId”:“3”}],“resourcedata”:[{“id”:“1”,“text”:“QA”,“parent”:“null”,“value”:""},{“id”:“2”,“text”:“Development”,“parent”:“null”,“value”:""},{“id”:“3”,“text”:“Sales”,“parent”:“null”,“value”:""},{“id”:“4”,“text”:“Other”,“parent”:“null”,“value”:""},{“id”:“5”,“text”:“Jhon”,“parent”:“1”,“value”:""},{“id”:“6”,“text”:“Mike”,“parent”:“2”,“value”:""},{“id”:“7”,“text”:“Anna”,“parent”:“2”,“value”:""},{“id”:“8”,“text”:“Bill”,“parent”:“3”,“value”:""},{“id”:“9”,“text”:“Floe”,“parent”:“3”,“value”:""}]}}

Index.html

Work and material resources html, body { padding: 0px; margin: 0px; height: 100%; } #gantt_here { width:100%; height: 800px; height:calc(100vh - 52px); } .gantt_grid_scale .gantt_grid_head_cell, .gantt_task .gantt_task_scale .gantt_scale_cell { font-weight: bold; font-size: 14px; color: rgba(0, 0, 0, 0.7); } .folder_row { font-weight: bold; } .highlighted_resource, .highlighted_resource.odd { background-color: rgba(255, 251, 224, 0.6); } .gantt_task_cell.week_end { background-color: #e8e8e87d; } .gantt_task_row.gantt_selected .gantt_task_cell.week_end { background-color: #e8e8e87d !important; } .group_row, .group_row.odd, .gantt_task_row.group_row { background-color: rgba(232, 232, 232, 0.6); } .owner-label { width: 20px; height: 20px; line-height: 20px; font-size: 12px; display: inline-block; border: 1px solid #cccccc; border-radius: 25px; background: #e6e6e6; color: #6f6f6f; margin: 0 3px; font-weight: bold; } .resource-select-panel .gantt_layout_content { line-height: 35px; text-align: right; padding-right: 15px; overflow: hidden !important; } .resource-select { padding: 3px; margin-left: 13px; } .column_overload .gantt_histogram_fill { background-color:#ffa9a9; }


#11

Hello Juan,
I added the data from your server into the snippet and reproduced the issue:
https://snippet.dhtmlx.com/5/8cd2d0474
First, I see that you load the null parameter as "null" which is a different value for Javascript. Instead of a falsy value, you pass a regular string:
https://www.w3schools.com/js/js_datatypes.asp
As there is no resource with such ID, the resources with such value in the parent parameter are not displayed.
After changing it to null, the resources are correctly loaded and displayed:

Then I see that John is not displayed.
It happens because of the following strings:

var UNASSIGNED_ID = 5;
if(!task.$virtual && (!ownerValue || !Array.isArray(ownerValue) || !ownerValue.length)) {
  task[gantt.config.resource_property] = [{resource_id: 5, value:0}];//'Unassigned' group
}

As you can see, the snippet expects the default resource with the ID 5. After changing it to a different ID, everything works correctly:
http://snippet.dhtmlx.com/5/0b5c1b9bc


#12

How about Ramil, in advance thank you very much for your support, and I understand what you are telling me, but how can I do it since with the gantt_connector.php, so it brings me the json, and I have tried a thousand things to be able to obtain it, and be able to change it On the other hand, bothering you, you think I can give you access to my team via teamviewer, so that you can support me, when you tell me the time and date to solve this problem, I have already invested a lot of time in this and I have not been able to solve, tell me if it has a cost to program it, and be able to solve it.

Waiting for your comments, and maybe if you can send me your email, I will gladly thank you.

Greetings and thank you very much


#13

Hello Juan,
Backend frameworks are beyond our support. If you want us to help you to integrate Gantt into your environment or implement something for you, I can contact you with the sales team.

If you cannot change the backend part, but can only change the client-side part, you can check the values in the JSON data and modify them before loading into Gantt:

var resourcedata = server_data.collections.resourcedata
for (var i = 0; i < resourcedata.length; i++) {
  if (resourcedata[i].parent === "null") resourcedata[i].parent = null;
}

Here is the snippet:
http://snippet.dhtmlx.com/5/36148cf03


#14

Hi Ramil
Thank you very much for the support, it already shows me the resourcedata from the bottom, but the resources still do not appear in each of the tasks as indicated in the image, just if you can help me to show them, since it does not It is placing them since I load the json, waiting for your comments and I reiterate the thanks for the support provided.


#15

Hello Juan,
It seems that you also need to convert the value in the owner parameter from String to Array:

var task_data = server_data.data
for (var i = 0; i < task_data.length; i++) {
  if (task_data[i].owner) task_data[i].owner = eval(task_data[i].owner)
}

Here is the updated snippet:
http://snippet.dhtmlx.com/5/e4faa7ecd