跳到主要内容

load

Description

从外部数据源将数据加载到甘特图

load: (url: string, type?: string, callback?: GanttCallback) => any

Parameters

  • url - (required) string - 服务器端 URL(可能是一个静态文件或输出数据的服务器端脚本)
  • type - (optionaL) string ('json', 'xml', 'oldxml') - 数据类型。默认值 - 'json'
  • callback - (optionaL) function - 回调函数

Returns

  • resultPromise - (object) - 当 Ajax 请求完成时解析的 Promise 对象

Example

gantt.load("/data",function(){
gantt.message("everything is ready");
});
//或者
gantt.load("/data").then(function(xhr){
gantt.message("everything is ready");
});
//或者
gantt.load("data.json"); //加载JSON格式的数据
//或者
gantt.load("data.xml","xml"); //加载XML格式的数据(版本2.0及以上)
//或者
gantt.load("data.xml","xml", function(){ //提供回调函数
alert("数据已成功加载");
});

Details

此方法会触发 onLoadStartonLoadEnd 事件。

注释

请注意,该方法在 Node.js 版本的 Gantt 中不可用。

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.