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
close icon

Editing and modifying values on the SfDataGrid

Hi,

One issue I'm having with modifying values on the SfDataGrid is that once I save the modified values the grid jumps to the first grouped column on the grid.

For example, if I have a SfDataGrid grouped by "Animal" in the following order:

  • Dog
  • Cat
  • Fox
  • Lion

If I modify and save a record in the "Lion" group the grid will move me up to the Dog group causing me to completely lose my place on the grid. Is there a way to allow saves to remain on the record you just modified?

My second question is, if I'm on a specific record in the "Lion" group and I change the animal of that record to a "Cat", is there a way to prevent that record from being grouped to the "Cat" group right away? I'd want to hold off on automatically changing groups of changed animal values.

A timely response would be appreciated, thanks!

9 Replies

MK Muthukumar Kalyanasundaram Syncfusion Team July 1, 2015 01:56 PM UTC

Hi  Ari Case,

Thank you for using Syncfusion products.

We analyzed your query. You can achieve your requirement by setting LiveDataUpdateMode property as Default. Please refer the following code snippet and sample:

Code Snippet:

<syncfusion:SfDataGrid Name="sfDataGrid"

                       AllowGrouping="True"

                       AllowEditing="True"

                       ShowGroupDropArea="True"

                       AllowFiltering="True"

                       AllowSorting="True"

                       AutoExpandGroups="True"

                       ItemsSource="{Binding OrderInfoCollection}" 

                       LiveDataUpdateMode="Default"
                       AutoGenerateColumns="False">



Sample: ModifyValueOnSfGrid

Please let us know if this solution helps you.

Regards,
Muthukumar K



AC Ari Case July 1, 2015 03:13 PM UTC

That didn't resolve my problem. 

It seems as though after I updated my Syncfusion version, modifying data on the grouped grid no longer jumps to the first grouped column like before, so this worked without me setting LiveDataUpdateMode="Default".


However the main issue I'm trying to resolve is what I mentioned previously:

My second question is:

  1. If I'm on a specific record in the "Lion" group and I change the animal of that record to a "Cat", is there a way to prevent that record from being grouped to the "Cat" group right away? I'd want to hold off on automatically changing groups of changed animal values.
  2. The other alternative would be if I change the animal of that record from Lion to Cat,the cursor should move to that record in the new Cat group.

I'd ultimaetly want to go to with the more optimal solution.



MK Muthukumar Kalyanasundaram Syncfusion Team July 2, 2015 05:57 PM UTC

Hi Ari,

Thanks for the update.

Query 1: It seems as though after I updated my Syncfusion version, modifying data on the grouped grid no longer jumps to the first grouped column like before, so this worked without me setting LiveDataUpdateMode="Default".

In our source itself,  we have set the LiveDataUpdateMode as Default, so there is no need to again set LiveDataUpdateMode as Default in SfDataGrid definition.

Query 2 -1: If I'm on a specific record in the "Lion" group and I change the animal of that record to a "Cat", is there a way to prevent that record from being grouped to the "Cat" group right away? I'd want to hold off on automatically changing groups of changed animal values.

If we set LiveDataUpdateMode as “AllowDataSharping” and modified the value of grouped records, the record will be moved to the corresponding group or it will create a new group. This is default behavior for SfDataGrid. If you want to prevent the record from moving to the group after edit, you can set LiveDataUpdateMode as Default. The record then would not get moved to another corresponding group to refresh the grid.

Query 2 -2: If I change the animal of that record from Lion to Cat,the cursor should move to that record in the new Cat group.

You can move the cursor to the changed group record position, by using the  MoveCurrentCell() method. Please refer to the below code snippet and attached sample,

Code Snippet:
this.sfDataGrid.CurrentCellEndEdit += sfDataGrid_CurrentCellEndEdit;

void sfDataGrid_CurrentCellEndEdit(object sender, CurrentCellEndEditEventArgs args)

{

   this.Dispatcher.BeginInvoke(new Action(() =>

     {

       this.sfDataGrid.MoveCurrentCell(new RowColumnIndex(args.RowColumnIndex.RowIndex, args.RowColumnIndex.ColumnIndex));


     }), DispatcherPriority.ApplicationIdle);
}



Sample: SfGrid_ModifyValue

Please let us know if you have any other questions.

Regards,
Muthukumar K



AC Ari Case July 9, 2015 03:49 PM UTC

Interestingly enough I implemented the change you prescribed and it did the opposite.

It actually prevented the modified row from moving to the new group that it belongs to which is what I wanted originally.

I'm satisifed with what this does but it's interesting that the sfDataGrid.MoveCurrentCell in the Dispatcher.BeginInvoke()"  method does this.

All in all I got what I want, thanks.


MK Muthukumar Kalyanasundaram Syncfusion Team July 10, 2015 10:07 AM UTC

Hi Ari,

Thank you for your update.

We are glad to know that, your issue has been resolved. Please let us know if you need any further assistance in future regarding Syncfusion Products.

Thanks & Regards,

Muthukumar K



AC Ari Case July 17, 2015 02:34 PM UTC

Your example works but the main difference is that you're binding to your grid with hard coded values.

I'm binding to mine using a DataView, maybe there's something with the way I'm binding that's causing this, it's been a problem for awhile now and I really need it resolved.

I'm binding like this:

DataView dataView = new DataView(myTable.Employees)
sfDataGrid.ItemSource = dataView.ToTable();

I'm also using 2 GridComboBox columns which I had to create a Control Template and Style for in the XAML to get it to display properly, I don't know if this helps narrow down what the issue is.

Also, is there a way I can securely send you guys an example of my code so you can take a look?





AN Ashok N Syncfusion Team July 20, 2015 06:19 PM UTC

Hi Ari ,

Thanks for the update .

We analyzed your query “Need to  avoid modifying Rows in a  DataTable collection with Grouping  case “. We regret  to inform you that your requirement is not achieved with DataTable collection . Because DataTable behave differently in this case. By default , the data will be reordered based on the sorted order  if the underlying collection type is  DataTable . This is the default behavior of DataTable collection type .

Please let us know if you require  further assistance on this .

Regards ,

Ashok



AC Ari Case July 20, 2015 08:15 PM UTC

I think you responded to my thread with someone else's issue.


AN Ashok N Syncfusion Team July 22, 2015 03:36 AM UTC

Hi Ari ,

Please ignore our previous update  and please find the below responses for your query .

Query 1 :  Binding using DataView

We analyzed your query . We have checked the reported problem “Modified row gets pushed to the last row of the group “  with the DataView  . We regret to inform you that we are unable to reproduce the reported problem in grouping case.

We have prepared the sample based on code snippet provided in your last update. Please find the sample from the following location ,

Sample : http://www.syncfusion.com/downloads/support/forum/119586/ze/SfDataGridSample-1712716125

Please refer the below video  for your reference ,

Video : http://www.syncfusion.com/downloads/support/forum/119586/ze/Video1460915304


Could you please confirm whether you have defined LiveDataUpdateMode as AllowDataShapping in your application .

Query 2 : I'm also using 2 GridComboBox columns which I had to create a Control Template and Style for in the XAML to get it to display properly, I don't know if this helps narrow down what the issue is.

We are not able to understand this query clearly and we need more information on this. Could you please confirm whether you have faced any UI related problem with GridComboBoxColumn and it could be resolved by customized style which is   display properly in GridComboBoxColumn . Also please let us know whether you have mentioned  the issue  which  related to the above data reordering problem or did you faced any other issue with GridComboBoxColumn . This would be helpful to  analyze further on this.

Query 3 : Also, is there a way I can securely send you guys an example of my code so you can take a look?

You can send the sample through this forum thread and it is possible to send the sample securely by  creating new incident . Could you please confirm whether you need to create new incident for this .

Please let us know if you require further assistance on this .

Regards,
Ashok


Loader.
Live Chat Icon For mobile
Up arrow icon