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

Update of the current record is updating everything!

First of all, your tool is awesome!
I'm having hard time on updating the content in the grid. 

 I set the DataSource programmatically the way below:
this.grdTranslationsList.DataSource = new TranslationDAO(ConnectionFactory.GetSession()).GetAll(); //This method returns a list of objects

I'm trying to set the values the way below:
Record selectedRecord = this.grdTranslationsList.Table.CurrentRecord;
selectedRecord.SetValue("InternalName", translationEntity.InternalName);
selectedRecord.SetValue("ExternalName", translationEntity.ExternalName);
selectedRecord.SetValue("TranslationTypeEntity_Name", translationEntity.TranslationTypeEntity.Name);
selectedRecord.SetValue("DateUpdate", translationEntity.DateUpdate);
selectedRecord.SetValue("UserUpdate_Username", translationEntity.UserUpdate.Username);

But for some reason, all the UserUpdate_Username fields in the grid gets updated, and even the field UserInclusion_Username which i'm not updating at all, gets updated. Could you help me please!?


9 Replies

VA Vanderson assis da silva July 11, 2016 07:21 PM UTC

I've noticed that it updates all the fields that has the same value of the edited field. 
E.g: I load a UpdateUser_Username field that have a value of "AlineRoque" and update it with the value "GabrielaAssis", then all "AlineRoque" values in the grid get updated with the "GabrielaAssis" value.

VS Venkatesh Sundaram Syncfusion Team July 12, 2016 10:32 AM UTC

Hi Vanderson, 
Thank you for using Syncfusion products. 
We had analyzed your reported scenario. Unfortunately we could not able to reproduce your reported scenario. Here we have provided the sample based on your scenario.  We need some more details about your issue. Could you please provide us with the following details,  
1. Can you please ensure whether the reported issue is reproducing in the attached sample?  
2. Could you please modify the sample with your customization we missed.  

VA Vanderson assis da silva July 12, 2016 04:04 PM UTC

Hi! Thank you for the reply.
It seems to be some kind of bug with NHibernate list. Or I may be missing something. What happens is that, when I use: 
as the datasource, the problem mentioned occurs. But when I use a for to instantiate each object, add it to the list and return the list, the problem doesn't occur. Hope that help you guys to help me heheheheh....because I really don't want to have to instantiate each object to every grid i'll have to edit.

One more thing. I'm not editing direct in the cell. I load the values to a text field, the user edit it, hit save and then I save to the database. The saving rountine is working fine. The problem is when I try to update the values in the grid.

VA Vanderson assis da silva July 12, 2016 05:50 PM UTC

I know now what the problem is, but don't know how to solve it!
My data structure is:

    int Id {get;set;}
    string InternalName {get;set;}
    string ExternalName {get;set;}
    UserEntity UserUpdate {get;set;} This is a custom object giving me problem

My datasource has a list of the above entity.
Now lets say I do selectedRecord.SetValue("UserUpdate_Username", "New value for this cell"); the value is not applied for the cell itself, but the UserUpdate instance in the grid. But what I want is to edit only the selectedRecord cell, not the UserUpdate instance.

Just for testing purpose I've filled the list the way below and the issue occurred. The problem with the "solution" in red, is that since i'm using NHibernate, i'm not looping anything, all I do is return the criteria.List<TranslationEntity>() method, and even if I was considering on looping though the NHibernate result and instantiating an instance for each row, that would not be appropriate, for memory limitations concerns. I'm sorry for the huge text, but I really need to solve this! =/

        public IList<TranslationEntity> GetTest()
            List<TranslationEntity> list = new List<TranslationEntity>();
            UserEntity userUpdate = new UserEntity();"SOLUTION" When I instantiate this object OUTSIDE the for loop, the error OCCURS, but when I instantiate it inside the for loop, the error DOESN'T OCCUR.

            for(int i = 0; i < 50; i++)
                TranslationTypeEntity typeEntity = new TranslationTypeEntity();
                typeEntity.Id = 12;
                typeEntity.Name = "Programa";
                userUpdate.Id = 12;
                userUpdate.Username = "vandeg";

                TranslationEntity entity = new TranslationEntity();
                entity.Id = 12;
                entity.InternalName = "Nome Interno " + i;
                entity.ExternalName = "Nome Externo" + i;
                entity.DateInclusion = DateTime.Now;
                entity.DateUpdate = DateTime.Now;
                entity.TranslationTypeEntity = typeEntity;
                entity.UserInclusion = userInclusion;
                entity.UserUpdate = userUpdate;


            return list;

VA Vanderson assis da silva July 12, 2016 07:50 PM UTC

In a nutshell, what I need is to update the TEXT of the cell, not the underlying object or any other thing. It's a visual thing. I'm not using the grid to save the values, only to display them. 
That's how i'm doing; a user right-click a row and then click the edit button, all the values from that row gets loaded in text boxes, that's where the values are being edited, after the user have edited, he pushes the save button, then I load the text boxes values in an object instance and save it using NHibernate. What I need to do next, is to load those values that were saved in the selected row. Just the user sees that it has changed, nothing else.

VS Venkatesh Sundaram Syncfusion Team July 13, 2016 12:33 PM UTC

Hi Vanderson,    
Thank you for your update.    
By the given information, we had created the simple sample for testing purpose. We tried to replicate the scenario in that sample, but we are unable to reproduce it. In that sample, we used the Cell click event to update the value of the current record. Please replicate the issue which you are facing in the below sample.  

VA Vanderson assis da silva July 13, 2016 04:42 PM UTC

I messed around my project and "kind of" got rid of the bug, but now there's a new one. I edited the source you sent me, and reproduced the bug i'm stuck with now. 
All I did in your source, was to comment some lines out of the gridGroupingControl1_TableControlCellClick event. If you run the project, you'll notice that only on the first click the UserUpdate_Username field gets updated, the next ones don't update the field. And even with the source you sent me, there's another bug, when you first click a cell, the UserUpdate_Username field doesn't update, only from the second click and so on it updates.

Thanks for the help!

Attachment: Sample244300935EDITED_6335bd5f.rar

VA Vanderson assis da silva July 13, 2016 07:07 PM UTC

I've made it! =D

What I did is, after the user changes some data and save it, I loop through the datasource list and apply the changes in THE list not in the recodt itself. After I update the list item, I call the method gridGroupingControl.Table.CurrentRecord.CompareAndUpdateValues(); and everything works fine! Finally =D...thank you for your help Vankatesh Sundaram!! 

VS Venkatesh Sundaram Syncfusion Team July 14, 2016 05:49 AM UTC

Hi Vanderson, 
Thanks for the update. Please let us know if you need any further assistance. 

Live Chat Icon For mobile
Up arrow icon