menglin
October 16, 2024, 9:52am
#1
An Invalid JSON Data error is displayed for exporting.
My version is 7.1.13 Business Edition.
step 1. You can export the product normally the first time.
setp 2. Close the page and open other Gantt chart exports error.A new Gantt chart instance is created each time a Gantt chart is opened
A new Gantt chart instance is created each time a Gantt chart is opened
menglin
October 17, 2024, 9:25am
#2
@ramil
My plugin is set up like this
gantt.plugins({
fullscreen: true,
critical_path: true,
// 自动编排插件
auto_scheduling: true,
undo: true,
marker: true,
keyboard_navigation: false,
multiselect: true,
export_api: true
})
Hello,
Unfortunately, I am unable to reproduce the issue. However, I have prepared an example for you to check out: DHTMLX Snippet Tool . To create a new Gantt instance, please click the “New gantt” button.
menglin
October 18, 2024, 2:45am
#4
Thanks,
I’ve found out why.
This ‘https://export.dhtmlx.com/gantt/api.js ’ link has not been reintroduced.
I introduced the link by way of fromCDN.
I don’t understand why it was introduced this way and then introduced the same way the second time why it didn’t work.
Each time the button is clicked, the exportPdf function is executed.
The following code is normal。
// 导出pdf
const exportPdf = () => {
const script = document.createElement(‘script’);
script.src = ‘https://export.dhtmlx.com/gantt/api.js ’;
script.async = true;
script.onload = () => {
console.log(vm,‘vm.data.schedule’)
// 脚本加载完成后的操作
if(!_gantt.value) return ElMessage.warning(‘请刷新页面重置gantt’);
_gantt.value?.exportToPDF({
name: ${vm.data.scheduleInfo?.objectName??'gantt'}.pdf
,
locale:“cn”,
server: pdfLink.value + “/gantt”,
raw:true,
// callback: function(res){
// console.log(res,‘导出pdf’)
// // document.body.removeChild(script);
// }
});
setTimeout(() => {
// 一分钟后清除当前script
script && document.body.removeChild(script);
}, 60000);
};
document.body.appendChild(script);
}
1 Like