Ganttchart - save/update models

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I'm new to all of this. I trie to use Dhtmxl Ganttchart (jquery) as a project-tool. There is no problem in retrieving data from models but when i make changes i dont know how to save them back into SF.

var element = arguments[0], $ = skuid.$;

element.html('<div id="gantt_omr" style="width:100%; height:800px;"></div>');

$(document).ready( function() {
    var omrModel = skuid.model.getModel('Omrade');
    var omrId =[0].Id;
    var omrTask = {id: omrId, text:[0].Name, open: true, type:"project", /*color: "colorcode"*/};
    console.log (omrTask);
    var doModel = skuid.model.getModel('Delomraden');
    var doTasks = [];
    var aoModel = skuid.model.getModel('AO');
    $.each(, function (i, doRow){
       doTasks.push({id: doRow.Id, text: doRow.Name, open: true, type:"project", parent: omrId});
       doTasks.push({id: 'P' + doRow.Id, text: 'Projektering: ' + doRow.Name, start_date: doRow.Start_projektering__c, end_date: doRow.Slut_projektering__c, open: true, type:"task", progress: doRow.Projektering_klar_p__c, parent: doRow.Id});
       doTasks.push({id: 'I' + doRow.Id, text: 'Installation: ' + doRow.Name, start_date: doRow.Start_kundinstallation__c, end_date: doRow.Slut_kundinstallation__c, open: true, type:"task", progress: doRow.Kundinstallation_klar_p__c, parent: doRow.Id});
       doTasks.push({id: 'S' + doRow.Id, text: 'Stam: ' + doRow.Name, open: true, type:"project", parent: doRow.Id});
       $.each(, function (j, aoRow){
          if(aoRow.Delomrade__c == doRow.Id) {
              doTasks.push({id: aoRow.Id, text: aoRow.Name, start_date: aoRow.Planerad_start__c, end_date: aoRow.Planerad_klart__c, open: true, type:"task", parent: 'S' + doRow.Id /*color: aoRow_color__c*/});
    var omrData = {
        var sampData = {
            {id:1, text:"Project #1", open: true, type:"project"},
            {id:2, text:"Task #1",   start_date:"2015-03-05", duration:5, progress: 1,   open: true, parent:1},
            {id:3, text:"Task #2",   start_date:"2015-03-07", duration:7, progress: 0.5, open: true, parent:1},
            {id:4, text:"Task #2.1", start_date:"2015-03-08", duration:2, progress: 1,   open: true, parent:3, color: "red"},
            {id:5, text:"Task #2.2", start_date:"2015-03-10", duration:3, progress: 0.8, open: true, parent:3, color: "red"},
            {id:6, text:"Task #2.3", start_date:"2015-03-11", duration:4, progress: 0.2, open: true, parent:3, color: "red"}
            {id:1, source:1, target:2, type:"1"},
            {id:2, source:1, target:3, type:"1"},
            {id:3, source:3, target:4, type:"1"},
            {id:4, source:4, target:5, type:"0"},
            {id:5, source:5, target:6, type:"0"},
            {id:6, scurce:6, target:7, type:"0"}
    myGantt = $("#gantt_omr").dhx_gantt({
        xml_date: "%Y-%m-%d",
        scale_unit: "week"
     // $("#gantt_omr").dhx_gantt().parse(omrData).config.xml_date("%Y-%m-%d");
Photo of Teodor Jansson

Teodor Jansson

  • 90 Points 75 badge 2x thumb
  • confident

Posted 3 years ago

  • 1
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Hi, have you checked out the JavaScript tutorials?  Take a look here:

There is an example for performing CRUD ops on models and rows.

You can also search the community for examples on working with models in JS.