Our state of the art Gantt chart


Post by jim@jimclark.net.au »

Have created a test ASP .NET WebAPI as backend for Gannt data. The Get is working fine for Transport Load but cannot get the post working on the sync.
Can you advise on using POST via CRUD for Gantt.

This is all based on the advanced vue.js demo..

const ganttConfig = {    
    startDate : '2019-01-06 00:00',
    project : new ProjectModel({
        taskModelClass : Task,
        transport       : {    
            autosync: true,                 
            load : {  
               // url : 'datasets/launch-saas.json'   
                requestConfig: {
                    method: 'GET',
                    url: 'https://localhost:58419/api/values/5',
                  }       
            },
            sync    : {
                requestConfig: {
                    method: 'POST',
                    url: 'https://localhost:58419/api/Save',
                  }                   
            }

        }
    }),

ASP.NET WebApi
 public class ValuesController : ApiController
    {
        [EnableCors(origins: "*", headers: "*", methods: "*")]
        // GET /api/values/5
        public Gantt Get(int id)
        {
            Gantt gantt = new Gantt();
            gantt.success = true;
            gantt.project.calendar = "general";
            TaskRow r = new TaskRow();
            r.name = "name of taks";
            r.percentDone = 25;
            gantt.tasks.rows.Add(r);
            return gantt;
        }

        [EnableCors(origins: "*", headers: "*", methods: "*")]
        // POST api/values
        public void Post([FromUri]Gantt value)
        {
            Debug.WriteLine(value.success);
        }

    }

Post by jim@jimclark.net.au »

How can I force a call to sync?
And if I can force a sync am I right in understanding it will send a PUT to the given url "'https://localhost:60832/api/Sync". ?
const ganttConfig = {    
    startDate : '2019-01-06 00:00',
    project : new ProjectModel({
        // Let the Pr oject know we want to use our own Task model with custom fields / methods
        taskModelClass : Task,
        transport       : {    
            autosync: true,                  
            load : {  
               // url : 'datasets/launch-saas.json'   
                requestConfig: {
                   // method: 'GET',
                    url: 'https://localhost:60832/api/Load/5',
                  }       
            },
            sync    : {
                url: 'https://localhost:60832/api/Sync',
            }

        }
    }),

Post by pmiklashevich »

Please see this config: https://www.bryntum.com/docs/gantt/#Scheduler/crud/transport/AjaxTransport#config-transport
It says "transport.sync.method ", which means:
const project = new ProjectModel({
    transport : {
        sync : {
            method : 'POST',
            url : 'test'
        }
    }
});
You can check how it works in "tooltips" demo locally (examples/tooltips/app.js):
const project = new ProjectModel({
    transport : {
        load : {
            url : '../_datasets/launch-saas.json'
        },
        sync : {
            method : 'POST',
            url : 'test'
        }
    }
});
Open it in a browser, drag an event to make the store dirty and call in console
gantt.project.sync()
See the exception due to missing url and pay attention to the method
AjaxHelper.js:100 POST https://lh/gantt/examples/tooltips/test 404 (Not Found)

Pavlo Miklashevych
Sr. Frontend Developer


Post by jim@jimclark.net.au »

works a charm , thanks

Post Reply