xml_format
Description
将日期对象转换为符合此模板的字符串。此方法用于将数据发送回服务器。
Parameters
date- (required) Date - 需要格式化的日期。
Returns
text- (string) - 将在甘特图中显示的HTML文本。
Example
gantt.templates.xml_format = function(date){
return gantt.date.date_to_str(gantt.config.xml_date)(date);
};
Details
注释
此模板已被弃用。请改用 format_date:
var dateToStr = gantt.date.date_to_str("%Y-%m-%d %H:%i");
gantt.templates.format_date = function(date){
return dateToStr(date);
};
此模板是从 xml_date 配置自动生成的,并且可以在Gantt初始化后重新定义。
如果服务器需要的日期格式不被Gantt日期助手支持,可以创建自定义模板函数。
例如,如果服务器期望 start_date 以 UNIX 时间戳格式传递,请求参数应为:
- start_date:1503608400
- duration:4
- text:Task #2.2
- parent:3
- end_date:1503694800
则甘特配置可设置如下:
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");
Related API
Related Guides
Change log
- 自v6.2起弃用,自v7.0起移除
Need help?
Got a question about the documentation? Reach out to our technical support team for help and guidance. For custom component solutions, visit the Services page.