How to set column index for unbound column

I have a SfDataGrid bound to an array of an object (TInventory). TInventory contains various members, each of which have the [Display(Order=?)] attribute. After binding the data to the grid, I manually add a couple unbound columns. I want to put these columns *BEFORE* one of the columns that were automatically generated from the data. However, there doesn't seem to be a way to set the index on a new unbound column-- they will always be added to the end.

Is there a way to accomplish this? Am I missing something?

Thanks,
Kevin

1 Reply 1 reply marked as answer

DM Dhanasekar Mohanraj Syncfusion Team December 18, 2020 09:28 AM UTC

Hi Kevin Swanner, 

Thank you for using Syncfusion controls. 

You can insert the UnboundColumn anywhere in the SfDataGrid with the index like below, 
GridUnboundColumn unboundColumn = new GridUnboundColumn(); 
unboundColumn.MappingName = "UnboundColumn"; 
unboundColumn.HeaderText = "Unbound Column"; 
unboundColumn.Expression = "OrderID-1000"; 
sfDataGrid1.Columns.Insert(2,unboundColumn); 

We have prepared the sample for the same,

 
 
Screenshot: 
 
 
We hope it helps, please let us know if you need further assistance. 

Regards,
Dhanasekar Mohanraj.

 


Marked as answer
Loader.
Up arrow icon