RadGridView in RowDetailsTemplate of RadGridView redraws improperly when modal dialog is displayed

0 Answers 16 Views
GridView
Ken
Top achievements
Rank 1
Ken asked on 06 Jul 2022, 03:25 PM | edited on 07 Jul 2022, 01:42 PM

I have a grid where some rows have a sub grid.  If the user clicks the row's toggle button, it shows the grid.

The problem happens if the user does anything on the page to show a modal. We do this by adding our dialog view to the outer region, then blocking. As soon as the block is called you can see it drops all columns of the grid but the first. The grid remains that way after you close the dialog. This is not limited to this view, I have found other places where we have a GridView in a row and it behaves the same when a modal is shown.

You can see this in the attachments.

Any help would be appreciated.

EDIT: added snippet showing dialog open

Stenly
Telerik team
commented on 12 Jul 2022, 01:11 PM

I have created a sample project, in order to try and reproduce this, however, I was not able to observe the specified behavior. I have attached the test application so could you give it a try?
Ken
Top achievements
Rank 1
commented on 20 Jul 2022, 07:53 PM

This is going to sound odd, but I could not get a simple WPF application to even show a RadButton, let alone get your example working. I even tried your VS extension to create Telerik projects.

Also, you missed the point about how we are showing our modals.  It's added to a region then given control via blocking the main thread.  I am sure this has something to do with the issue:

                var dialogRegion = _regionManager.Regions[DialogRegion];
                dialogRegion.Add(view);

                var first = dialogRegion.ActiveViews.LastOrDefault() as FrameworkElement;

Since I couldn't get your solution to work I decided to see if I could run a refresh on the items in the grid...and it worked.  I have a function RefreshNestedGrids which iterates through all controls in my "MainRegion" looking for a grid in a grid and refreshing the items in the the grid, then the sub grid is displayed as expected.  Oddly enough I needed to do this both before the block and after the dialog closed.

Are there any known issues with regions & Telerik?

FYI: we are currently using the 2022.1.222 version of the WPF controls. This comes from our own nuget feed and that's the highest version on the feed.

Martin Ivanov
Telerik team
commented on 25 Jul 2022, 08:48 AM

The missing controls (like RadButton) that you mentioned probably relates to the usage of the NoXaml version of the Telerik dlls. You can read more about this here: https://docs.telerik.com/devtools/wpf/common-information/troubleshooting/invisible-controls. In order to run Stenly's project you will need to reference the Xaml version of the dlls.

As for the issue at hand, the usage of PRISM regions shouldn't be related to this. However, you can never be sure. Anyway, my guess here is that the issue is related to the moment when the dialog is opened. Can you please show me how and when exactly the dialog is opened? If for some reason this happens during the measure/arrange phase of the GridView, the reported issue can occur. The measure/arrange phase can be started on different occasions like resizing of the control, data updates, grouping, sorting, etc. Basically, any operation that requires to redraw the viewport. If this is the case, then you will need to wait for the measure/arrange to finish before showing the dialog. Or you should show it before that.

Ken
Top achievements
Rank 1
commented on 25 Jul 2022, 03:10 PM

Funny, I was just reading about the difference between the Xaml & NoXaml.  I got the OK on Friday to upgrade the controls to the latest version.  I will be doing that today and seeing if it fixes the issue. 

The dialog is controlled by the user and they cannot open it until after the Screen has finished loading.

Here is the code used to add the dialog, in a method called Show:

                var dialogRegion = _regionManager.Regions[DialogRegion];
                dialogRegion.Add(_view);

Here is the ShowModal method, invoked by the user, with my RefreshNestedGrids hack:

        public void ShowModal(FrameworkElement view)
        {
            var blocker = _threader.NewBlocker();

            OnClose += (sender, args) =>
            {
                RefreshNestedGrids();
                blocker.Unblock();
            };

            Show(view);
            RefreshNestedGrids();
            blocker.Block();
        }

 

        private void RefreshNestedGrids()
        {
            var top = _regionManager.Regions[MainRegion];
            foreach (var activeView in top.ActiveViews)
            {
                var element = activeView as FrameworkElement;
                if (element != null)
                {
                    //Search for grids in this view
                    var grids = element.ChildrenOfType<RadGridView>();
                    if (grids != null)
                    {
                        //Now see if any of the grids have a sub grid, and if so, refresh it.
                        foreach (var grid in grids)
                        {
                            var rowGrids = grid.ChildrenOfType<RadGridView>();
                            if (rowGrids != null && rowGrids.Count() > 0)
                            {
                                grid.Items.Refresh();
                            }
                        }
                    }
                }
            }
        }
Martin Ivanov
Telerik team
commented on 28 Jul 2022, 12:53 PM

Have you got the chance to test the latest version?

A possible reason behind the issue could be the usage of the thread blocker. What exactly does it do and how?

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Ken
Top achievements
Rank 1
Share this question
or