How to add unmounted column in datagrid?

I have bound data with data table. Now I want to add new column in that grid at specific column. 

How to add column and set column type for this case?


3 Replies

SV Suja Venkatesan Syncfusion Team January 25, 2022 02:24 PM UTC

Hi Amish, 

You can achieve your requirement as like below code snippet. Also, we have prepared a simple sample for adding columns in the runtime based on your requirement and attached it in the below sample link.  

Code Snippet: 
int count = 0; 
viewmodel.DataTable.Columns.Add("Flag", typeof(int)); 
foreach (System.Data.DataRow a in viewmodel.DataTable.Rows) 
{ 
 a[4] = count; 
 count++; 
 viewmodel.DataTable.AcceptChanges(); 
} 
sfGrid.Columns.Insert(2,new GridTextColumn() { MappingName="Flag"}); 


Please revert us to with more details about your requirement with illustration or image and explain in detail about unmounted column which you mentioned in your previous update, if we misunderstand your requirement. 

Regards, 
Suja 



AM Amish replied to Suja Venkatesan January 27, 2022 05:47 AM UTC

Thank you very much. Problem solved.



SV Suja Venkatesan Syncfusion Team January 28, 2022 02:49 PM UTC

Hi Amish, 

We are glad that our solution meets your requirement. Please let us know if you need further assistance. As always, we are happy to help you out. 

Regards, 
Suja 


Loader.
Up arrow icon