当动态添加列时,ColumnsDirective的列值不显示。

问题描述 投票:0回答:1

我需要展示 栏目导演 动态地基于用户在许多字段中的选择,这些字段可能不仅是标准字段,也可能是用户的选择。GanttComponent 使用与 "开始 "文档中显示的一样。

this.taskFields = {
        id: 'TaskID',
        name: 'TaskName',
        startDate: 'StartDate',
        duration: 'Duration',
        progress: 'Progress',
        child: 'subtasks',
    };

当这些其他字段被包含在 栏目导演 初次 GanttComponent 显示,列上的单元格值将显示 enter image description here

但当这些字段在初始显示后被动态添加时,它们的值将不会显示在其列单元格中。

以下是一个 爆料 显示问题(截图)

我试着在taskFields中预先定义这些列,甚至在动态添加之前就开始了 栏目导演 但这并没有解决这个问题。

reactjs syncfusion gantt-chart
1个回答
0
投票

与其刷新整个甘特图,我们建议你通过使用showColumn和hideColumn公共方法动态地改变列的可见性。

<button type="button" onClick={ev => { 
   if (this.ganttInstance.getGridColumns()[2].visible) { 
     this.ganttInstance.hideColumn('fieldXX1'); 
   } 
   else { 
      this.ganttInstance.showColumn('fieldXX1'); 
   } 
}}>Change Comlumns</button>

示例------------。https:/stackblitz.comeditreact-6lscfc-yqzk6h?file=index.js。

我们还提供了解决方案,使用刷新方法刷新整个甘特图。

<button type="button" onClick={ev => { 
       //... 
  setTimeout(function () { 
    var obj = document.getElementById('Default').ej2_instances[0]; 
      obj.refresh(); 
  }, 100); 
}}>Change Columns</button> 

示例--------------。https:/stackblitz.comeditreact-6lscfc-n3xgjh?file=index.js。

© www.soinside.com 2019 - 2024. All rights reserved.