ej2 - JavaScript (ES5) & Blazor

Hello Team,

Just wondering, how can I use "ShowColumnOption" of   EJ1   https://help.syncfusion.com/js/gantt/columns#show-column-options in GanttChart EJ2

ShowColumnOption of EJ1 is an excellent option and I am looking to use it in my project.

It's not necessary that I have to use only with ej2 Gantt Chart, I am also okay if you help me to invoke ShowColumnOption to add column to any persistent class or Gridview

Thank you
Pooja









3 Replies

KR Karthikeyan Raja Syncfusion Team February 19, 2020 12:45 PM UTC

Hi Pooja,   
  
Sorry for the delay.   
Currently Gantt have support for columnMenu. By using columnMenuItems API we can add custom items as per requirement and using columnMenuClick event we can perform the actions for the added item. Please find the code snippet below,   
var ganttChart = new ej.gantt.Gantt({   
//……   
   columnMenuItems:[{text:'InsertColumn'id:'insert'}],   
   columnMenuClick: function(args){   
      if(args.item.id === 'insert'){   
         var insertIndex = 2;   
         var colObj= { field: 'Duration'headerText: 'Duration'width: 140};   
         this.treeGrid.columns.splice(insertIndex,0,colObj);     
         this.treeGrid.refreshColumns();    
       }   
   },   
  
We have prepared sample with your requirement. Please find the sample from below link,   
  
Please get back to us, if you need any further assistance on this 

Regards, 
Karthikeyan Raja 



PS Pooja Saraswat February 20, 2020 04:14 AM UTC

Hi Karthikeyan,

Thanks for your response and hope you are doing well.

Below code was helpful but I was looking to invoke below window where user can create a custom field dynamically including drop-down.

Insert dialog 

looking for your response

Many thx, Pooja


KR Karthikeyan Raja Syncfusion Team February 20, 2020 02:51 PM UTC

Hi Pooja,   
   
We have prepared a sample and rendered custom dialog for insert column on column menu click action using columnMenuClick event and also populated required fields in dropdown.  
Please find the code snippet below,   
var ganttChart = new ej.gantt.Gantt({   
//……   
   
    columnMenuItems:[{text:'InsertColumn Right'id:'insertRight'}, {text:'InsertColumn Left'id:'insertLeft'}],   
  columnMenuClick: function(args){   
     if(args.item.id === 'insertRight' || args.item.id === 'insertLeft'){   
        var columnindex = args.column.index;   
        insertIndex = args.item.id == 'insertRight' ? columnindex + 1 :columnindex ;   
        dialogObj.show();   
      }   
  },   
});   
var dialogObj = new ej.popups.Dialog({   
//……   
   buttons: [{   
     click: okClick,   
     buttonModel: { content: 'OK'isPrimary: true }   
  },   
  {   
     click: cancelClick,   
     buttonModel: { content: 'Cancel'cssClass: 'e-flat' }   
  }],   
   
});   
var listObj = new ej.dropdowns.DropDownList({   
//……   
   
});   
function okClick() {   
   var colObj= { field: listObj.valueheaderText: headertext.value };   
   ganttChart.treeGrid.columns.splice(insertIndex,0,colObj);     
   ganttChart.treeGrid.refreshColumns();   
   dialogObj.hide();   
}   
function cancelClick() {   
   dialogObj.hide();   
}   
   
   
   
Please find the sample from below link,   
Please get back to us if you require further assistance. 
 
Regards, 
Karthikeyan Raja 


Loader.
Up arrow icon