This is a migrated thread and some comments may be shown as answers.

Don't update UI after programm binding

3 Answers 153 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anton
Top achievements
Rank 1
Veteran
Anton asked on 14 Oct 2020, 12:38 PM

Hello.

 

I use RadGridView (2018.1.116.45).

I am create columns and set him binding in programm code as 

 

 

column = new GridViewDataColumn
                {
                    ColumnGroupName = args.ColumnDef.ColumnGroupName,
                 
                    DataMemberBinding = new Binding(args.ColumnDef.Member)
                    {
                        Mode = BindingMode.TwoWay,
                        UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                    },
                    IsReadOnlyBinding = new Binding(args.ColumnDef.IsReadOnlyMember)
                    {
                        Converter = new NullToBooleanConverter {IsInverted = true}
                    },
                   
                    Header = args.ColumnDef.Header,
                    IsVisible = true
                };

If i set cell value from UI all right, but if i set value from code UI not update, only after i select cell and try input value, value which i set erly will be placed in UI cell.

I try update view by programm code as

 var oldCellInfo = MainGrid.CurrentCellInfo;
            var gridViewCellInfo = new GridViewCellInfo(sender, gridViewColumn);
            MainGrid.CurrentCellInfo = gridViewCellInfo;

            MainGrid.CurrentCell?.BeginEdit();
            MainGrid.CurrentCell?.CommitEdit();
            
            MainGrid.CurrentCellInfo = oldCellInfo;
            MainGrid.CurrentCell?.BeginEdit();

            MainGrid.UpdateLayout();

 

But this is not working...

How i can update UI?

 

3 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 19 Oct 2020, 07:22 AM

Hello Anton,

Thank you for the provided code snippet.

May I ask you to share in which event you are trying to set the current cell? I am asking this because the first parameter in the GridViewCellInfo is the "sender" which is why I assume the code is placed inside an event handler. The CurrentCellInfo property is set to a new value, and then it is returned to its old one. Can you share if this is on purpose?

 var oldCellInfo = MainGrid.CurrentCellInfo;
 var gridViewCellInfo = new GridViewCellInfo(sender, gridViewColumn);
MainGrid.CurrentCellInfo = gridViewCellInfo;

 MainGrid.CurrentCell?.BeginEdit();
MainGrid.CurrentCell?.CommitEdit();
            
MainGrid.CurrentCellInfo = oldCellInfo;
MainGrid.CurrentCell?.BeginEdit();

MainGrid.UpdateLayout();

As a side note, you can check the following articles related to your scenario:

Regards,
Dinko
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
Anton
Top achievements
Rank 1
Veteran
answered on 19 Oct 2020, 08:20 AM

Hello.

This is my own event.

0
Dinko | Tech Support Engineer
Telerik team
answered on 20 Oct 2020, 10:57 AM

Hello Anton,

Can you share more information regarding this event? If you can isolate this behavior in a standalone project, that will be great. This way, I can have a better look at your set-up.

Regards,
Dinko
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
GridView
Asked by
Anton
Top achievements
Rank 1
Veteran
Answers by
Dinko | Tech Support Engineer
Telerik team
Anton
Top achievements
Rank 1
Veteran
Share this question
or