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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

sfDataGrid event on column order

Thread ID:





141114 Nov 25,2018 07:13 AM UTC Dec 3,2018 03:46 PM UTC WPF 3
Tags: SfDataGrid
Vasudeva Naik
Asked On November 25, 2018 07:13 AM UTC

I am controlling the column ordering, visibility, filtering etc everything from the view model by writing an adapter to separate view from view model. Things are working nice so far.
However, I need to preserve the order of the column that the user sets in once session so that I may represent him the same order when he launches the application again.
For this to happen, I need a event that will help me intimate the ViewModel that column reordering has happened. I saw this thread:
And also read the documentation here:
From the documentation, I see we can track the dragging of a column but can't find anything that can help us hook to the drop. Am I missing something.
All I need is a place to hook to when the user has reordered a column.


Deivaselvan Y [Syncfusion]
Replied On November 30, 2018 10:19 AM UTC

Hi Vasudeva,

Thank you for contacting Syncfusion support.

We have analyzed your query and we suspect that you have required to Serialization and Deserialization the order of the columns in SfDataGrid. DataGrid does not support to maintain to order of the columns during Serialization and Deserialization and it will maintain only data operation settings. However, we have prepared the simple sample by maintaining the order of the columns during DataGrid reloading by storing the columns order in xml file when it was unloaded. Please find the sample to illustrate this from the below link and let us know if this helps you.



Vasudeva Naik
Replied On November 30, 2018 11:02 AM UTC

I understand that we can save and restore the column order while loading and unloading. But in real life applications, flows arent that easy and we have to go by the user requirements rather than the functionalities offered by third party we use. Of course there are workarounds (seems we have to take one), but that needs lot of wrapper code which we want to avoid due to time constraint. 
Having said that, an event once a column is dragged and dropped (giving info about the colum and old/ new index) is a very logical thing to have. I see you have event to track the drag event of columns (cant see why we should not have drop event). 
From your reply, I assume there is no event to mark drop of a column. Can you please bring this to the notice of your dev? 

Deivaselvan Y [Syncfusion]
Replied On December 3, 2018 03:46 PM UTC

Hi Vasudeva,

You can use the QueryColumnDragging event to get the old and new column index when column dropped. Please refer the below code example which illustrate the same.

this.dataGrid.QueryColumnDragging += DataGrid_QueryColumnDragging; 
private void DataGrid_QueryColumnDragging(object sender, QueryColumnDraggingEventArgs e) 
    if(e.Reason == QueryColumnDraggingReason.Dropped) 
        int oldColumnIndex = e.From; 
        int newColumnIndex = e.To; 

Please let us know if you have any other questions.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon