Hi Shivani,
Greetings from syncfusion support
We have analyzed your query and we suspect that you like to add columns dynamically. By default in our Grid, when the column declaration is empty while initializing the Grid. All the Fields in the DataSource are bound as grid columns. Then the column Type will be determined from the first record of the DataSource.
Note: If you are not defined columns and datasource property in Component initialization. You have to set columns or datasource property to the Grid in the Load event to create Grid.
If you like to add the Columns dynamically, you can achieve this requirement by directly pushing the new column to the Grid’s columns property(which can be accessed using its instance). we suggest you to use our Grid inbuilt methods and call the refreshColumns() method for UI changes.
|
AddColumn() { //external button click function
var obj = { field: "NewColumn", headerText: 'NewColumn', width: 120 }
grid.columns.push(obj as any); //you can add the columns by using the Grid columns method
grid.refreshColumns();
}
|
Note: The Grid will re-render the columns when we calling the Grid’s refreshColumns method.
And if you still face the issue, Please share the below details that will be helpful for us to provide better solution.
1) Share your complete Grid rendering code.
2) If possible please share us issue reproducing sample. It would be helpful to identify your problem case better so that we can check and provide the solution based on that.
3) If possible please share the issue scenario in video demonstration.
Regards,
Rajapandi R