We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Add Columns Programatically Before They Are Auto Generated

Hi Syncfusion,

I could probably add columns something like this at any time:
var colObj = { headerText: "Ship City", field: "ShipCity", width: 120 };  

But I would like to add columns programatically but as early as possible. So basically add this programatically at run time:

Would it be possible to add this att the data grid's loaded or created event? And if so what is the best way to add it?


1 Reply

BS Balaji Sekar Syncfusion Team January 7, 2020 09:15 AM UTC

Hi Marius Lian, 
Greetings from Syncfusion Support. 
Query #1: Would it be possible to add column to Data Grid in Load or Created event ? 
We have analyzed your query and we can understand that you need to push columns to Grid as early as possible. Yes, you can add columns to Grid in the Load or Created events of Grid. We suggest you to use Load event. This event allows customization of Grid properties before rendering. We have achieved your requirement and created a sample based on your query. Please refer the below code snippet and sample link for more information. 
  <div id="app"> 

import Vue from "vue"; 
import { GridPlugin, Edit, Page, Toolbar } from "@syncfusion/ej2-vue-grids"; 
import { data } from "./datasource"; 


export default { 
  data() { 
    return { 
      data: data, 
      editSettings: { 
        allowAdding: true, 
        allowEditing: true, 
        allowDeleting: true 
      toolbar: ["Add", "Edit", "Delete", "Update", "Cancel"] 
  methods: { 
    load: function()
      var colObj = { headerText: "Ship City", field: "ShipCity", width: 120 }; 
  provide: { 
    grid: [Page, Edit, Toolbar] 

If we have misunderstood your query, please provide us more details that will be helpful for us to provide you better assistance. 
  1. Please share the full Grid rendering code.
Please get back to us if you need further assistance. 
Balaji Sekar. 

Live Chat Icon For mobile
Up arrow icon