xml_format

a date object is converted into a string in conformity with this template. Used to send data back to the server

dateDatethe date which needs formatting

Example

gantt.templates.xml_format = function(date){
    return gantt.date.date_to_str(gantt.config.xml_date)(date);
};

Details

The template is deprecated. Use format_date instead:

var dateToStr = gantt.date.date_to_str("%Y-%m-%d %H:%i");
gantt.templates.format_date = function(date){
    return dateToStr (date);
};

This template is automatically generated from the xml_date config and can be redefined after the initialization of gantt.

A custom template function can be used, if the server side expects a format that is not supported by the gantt date helper.

For example, let's say the server side expects start_date as a UNIX timestamp and the request parameters should look like this:

  • start_date:1503608400
  • duration:4
  • text:Task #2.2
  • parent:3
  • end_date:1503694800

You should set the Gantt configuration as follows:

gantt.attachEvent("onTemplatesReady", function(){
    gantt.templates.xml_format = function(date){
        return (date.valueOf() / 1000) + "";
    }
});
 
gantt.init("gantt_here");
gantt.load("/data");
 
var dp = new gantt.dataProcessor("/data");
dp.init(gantt);
dp.setTransactionMode("REST");
See also
Change log

deprecated since v6.2, removed since v7.0

Back to top