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

RowDetail record erased while sorting or filtering master grid.

5 Answers 145 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vinod
Top achievements
Rank 1
Vinod asked on 05 Dec 2011, 03:27 PM
Hi,
I have a gridview having a grid in its rowdetail, when row detail visibility changes i fetch data from database to load the row detail grid.
But the problem here is that when i sort or filter on the main grid, the data is removed from the already opened row detail grid.

Same thing happens when we have some controls in our rowdetails, and the values of expanded row details sets to blank when filtered or sorted.

Using "RowDetailsVisibilityChangedevent" to populate the rowdetails, due to some constraints not using "LoadingRowDetails".

Please let me know is there anything i can do so that those row detail grid data does not get removed when I do sorting or filtering on main grid.

Please reply its urgent.
Thanks

5 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 08 Dec 2011, 08:53 AM
Hello Vinod,

Generally the described behavior sounds very strange. Row detail is just an empty container that inherits its DataContext from the corresponding row of the master grid. It is up to you to create necessary bindings or call specific methods to load data accordingly. RadGridView just measures and arranges this container.
Could you please send me a sample project which I can debug on my side in order to see what is going on?

Regards,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Vinod
Top achievements
Rank 1
answered on 09 Dec 2011, 11:38 AM

Hi,
I won't able to provide the running project as I'm running short of time and won't be able to share the data, but here is the code what I'm using to populate the RowDetails not the "LoadingRowDetails".
Also attaching the screenshot of the row detail before and after - filtering, sorting or page size change of rad pager.

Code : (this method is called everytime I do filtering or sorting, where e.Visibility = Collapsed. this must be Visible for the expanded row.)

 

private void radGridUser_RowDetailsVisibilityChanged(object sender, GridViewRowDetailsEventArgs e)
        {
            try
            {
//this condition is used to check whether data is changed or not. only one row at a time.
                if (CurrentUserInfo.IsChanged == true && !_isRowDetailsChanged)
                {
                    ProgressScreen(true);
                    _isRowDetailsChanged = true;
                    MessageBoxResult result = CommonUIHelper.ShowMessage(ChaosMessage.CommonModifiedMsg, Constants.App, MessageBoxButton.YesNo,
                                   MessageBoxImage.Question);
                    if (result == MessageBoxResult.Yes)
                    {
                        ValidateAndSaveUserDetails();
                    }
                    else if (e.Visibility == Visibility.Visible && (e.Row as GridViewRow) != null && ((e.Row as GridViewRow).DataContext as UserInformation) != null)
                    
                        ClearMessage();
                        _isRowDetailsChanged = false;
                        CurrentUserInfo.IsChanged = false;
                        _objFrmWrkElementSelectedRow = e.DetailsElement;
//This method will fetch the details from the database on the basis of some ID passed to it and populate the rowDetail
                        LoadRowDetails(_objFrmWrkElementSelectedRow); 
                    }
                    else
                    {
                        _isRowDetailsChanged = false;
                        CurrentUserInfo.IsChanged = false;
                        ProgressScreen(false);
                    }
                }
                else if ((e.Visibility == Visibility.Visible && (e.Row as GridViewRow) != null && ((e.Row as GridViewRow).DataContext as UserInformation) != null))
                {
                    ClearMessage();
                    _objFrmWrkElementSelectedRow = e.DetailsElement;
//This method will fetch the details from the database on the basis of some ID passed to it and populate the rowDetail
                    LoadRowDetails(_objFrmWrkElementSelectedRow);
                }
            }
            catch (Exception objCEx)
            {
                //some code.
            }
        }

Is there any way to collapse the row detail, before applying sorting, filtering or pagination, by doing this we can just collapse the row, and if user expand it again data will be populated.

Thanks.

0
Rossen Hristov
Telerik team
answered on 09 Dec 2011, 01:34 PM
Hi Vinod,

Let me explain what row details are. They are a simple empty rectangle. Nothing more. This simple empty rectangle is either visible or collapsed. There is nothing more about row details -- a simple empty rectangle -- nothing less and nothing more. When this rectangle becomes visible or collapsed the RowDetailsVisibilityChanged event is fired. You can check whether it becomes visible or collapsed from the event argument.

The stuff that fills this rectangle is taken from the DataTemplate that you define and the parent row data item is set as its DataContext so that you can data bind stuff to it. When this process happens the LoadingRowDetails event is fired. This happens only once.

So we only provide this empty rectangle and we show and hide it. Nothing more, nothing less. All the rest is up to you -- all kinds of complex logic and binding are your creation and your responsibility. You could take an empty rectangle outside RadGridView, set its DataContext to be some data item, fill it up with the stuff that you placed in the DataTemplate and you would have absolutely the same thing. 

RadGridView does not have any kind of logic or knowledge about what is going on in this simple rectangle -- that is your responsibility. The only thing that RadGridView provides are the two simple events that I mentioned. What you do on those events is your concern and responsibility.

We can't be responsible for the custom user code that you have written in one of the event handlers.

I really hope that this makes sense. 

Regards,

Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Vinod
Top achievements
Rank 1
answered on 12 Dec 2011, 11:04 AM
Hi Ross,

I understood what you are saying. That is true and trying to do the same.
But in RowDetailsVisibilityChanged(object sender, GridViewRowDetailsEventArgs e) event, when I expand or collapse the rowDetails, the value for the

e.Visibility

= Visible; when expanded, and

 

e.Visibility

= Collapsed when collapsed. that is working fine.

Now when rowDetail is in expanded mode and when I just sort or filter the Parent Grid, it implicitly fires the RowDetailsVisibilityChanged event with the wrong e.Visibility value, for the row which has expanded RowDetails it also gives the e.Visibility = Collapsed. If this value is right which should be e.Visibility = Visible, then my code will work fine, because I only assign the DataContext if the rowDetails is visible.

Please let me know, why e.Visibility is giving wrong mode, when we filter or sort.
Thanks.

 

0
Maya
Telerik team
answered on 12 Dec 2011, 01:09 PM
Hi Vinod,

I have tried to reproduce the issue you reported, but still without any success. Could you take a look at the sample attached and let me know whether you can get the same behavior on it ? Am I missing something according to your scenario ?
 

Greetings,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Vinod
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Vinod
Top achievements
Rank 1
Rossen Hristov
Telerik team
Maya
Telerik team
Share this question
or