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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

sfDataGrid event on column order

Thread ID:

Created:

Updated:

Platform:

Replies:

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

Hi,
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:
https://www.syncfusion.com/kb/2437/how-to-set-back-the-initial-columns-order-after-reordering-the-columns
And also read the documentation here:
https://help.syncfusion.com/xamarin/sfdatagrid/columndraganddrop
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.

regards,
Sid

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.

http://www.syncfusion.com/downloads/support/forum/141114/ze/EditingDemo-2088218050.zip

Regards,
Deivaselvan 


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

Hi,
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? 
Thanks,


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.

Regards,
Deivaselvan 


CONFIRMATION

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

;