Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
Build object tasks for gantt.parse

The question is pretty trivial, but my level of programming doesn't allow me to solve it.

I'm trying to build an object, for display. Built it first with simple push method, then I realized there is an error and something is wrong.

Step by step, first I make ajax request to api server. I get data array, then I form object during enumeration. Example:

data = [];
$.ajax(settings).done(function (response) {
  obj = response.result.tasks;
  Object(obj).forEach(function (entry, index) {
    console.log(entry);
    startDatePlan = entry.startDatePlan.substring(0, 10);
    endDatePlan = entry.endDatePlan.substring(0, 10);
data.push ({id: entry.id, text:entry.title, start_date: startDatePlan, end_date: endDatePlan})    
  })
}); 

The output I get is an array like this:

[
    {
        "id": "7852",
        "text": "D#3628 7852",
        "start_date": "2021-10-21",
        "end_date": "2021-11-05"
    },
    {
        "id": "7854",
        "text": "D#3628 7854",
        "start_date": "2021-10-06",
        "end_date": "2021-10-21"
    },
    {
        "id": "7856",
        "text": "D#3628 7856",
        "start_date": "2021-09-28",
        "end_date": "2021-10-06"
    }
]

But this array doesn't work, having compared it to the demo version. I see that my properties are not defined as numbers and dates. But I can't figure out how to build the array correctly.

I even tried filling the object and pushing it into the array. But I faced with indices, which are not used in the demo.

gantt.parse({
    data:[
        {id:1, text:"Project #2", start_date:"01-04-2013", duration:18},
        {id:2, text:"Task #1",    start_date:"02-04-2013", duration:8,
            progress:0.6, parent:1},
        {id:3, text:"Task #2",    start_date:"11-04-2013", duration:8,
            progress:0.6, parent:1}
    ],
    links:[
        { id:1, source:1, target:2, type:1},
        { id:2, source:2, target:3, type:0}
  ]
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Let's continue our discussion here:

https://forum.dhtmlx.com/t/question-build-object-tasks-for-gantt-parse/73313

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!