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

GetDetailsViewGrid

So, I need to get a details view by a record index. 

I did so (the most obvious way): 
    <Grid>.GetDetailsViewGrid(<index>, "Details");
  Result: not working (returns null) - ok

Decompiled with Resharper: the record must be at least expanded - let's try:
    <Grid>.ExpandDetailsViewAt(<index>);
    <Grid>.GetDetailsViewGrid(<index>, "Details");
  Result: not working (returns null) - hmm

Decompiled with resharper, walked with debugger: 
  Item in <Grid>.RowGenerator.Items must be of DetailsViewDataRow type: going deeper...
  When it happens: bingo, when it's in a visible area and expanded - again:
    <Grid>.ExpandDetailsViewAt(<index>);
    <Grid>.ScrollInView(new RowColumnIndex(<Grid>.ResolveToRowIndex(<index>), 0));
    <Grid>.GetDetailsViewGrid(<index>, "Details");
  Result: not working (returns null) - what's wrong with you?!

After some period of time I tried to do smth again. What if I scroll down a little bit: 
  My item in <Grid>.RowGenerator.Items becomes DetailsViewDataRow - 0_o
  Well, I think there is some reason to do this way, but it's not obvious at all.
  Ok, let's try to scroll to the row that is after needed:
    Wheeeeee. It works!
  
But there's one little problem. I can't guess how to do this from code. 
  <Grid>.ScrollInView(new RowColumnIndex(<Grid>.ResolveToRowIndex(<index + 1>), 0));
  <Grid>.ExpandDetailsViewAt(<index>);
  <Grid>.GetDetailsViewGrid(<index>, "Details");
If I do this twice, then it works, because it updates grid and changes type of the item to DetailsViewDataRow. But if i call this method once, it's not working. And now I have no idea what to do next.

My xaml code and it's illustration are in the attachments

Attachment: Resources_2819d3c4.zip

11 Replies

SV Srinivasan Vasu Syncfusion Team November 7, 2016 12:37 PM UTC

Hi Andrew,
Thanks for contacting Syncfusion support.

We have checked your query and SfDataGrid will creates the DataRow in RowGenerator only for the rows currently in view. Hence you are not able to get the DetailsViewDataGrid which is in out of view and also you have to expand the corresponding parent record if it is not already expanded. You can bring the specifiedDetailsViewDataGrid into view, by usingDetailsViewManger.BringIntoView and ScrollInView method.

We have prepared the sample for this and please find the details below.

Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/MASTERDetails1707021264.zip

Help Documentation.

https://help.syncfusion.com/wpf/sfdatagrid/master-details-view#programmatically-expand-and-bring-detailsviewdatagrid-into-view

Regards,
Srinivasan




AN Andrew November 8, 2016 03:12 PM UTC

Well, this works, but what if i want to select some row in the expanded view and bring it to view?
Bringing to view is more important because SelectionIndex solves selection problem.
I modified your example a little bit to show my actions (added 20 rows to the ModelView's products with OrderId = 1013, added some code to the main window)

Attachment: MasterDetailsViewSample_74ad1a9e.zip


SV Srinivasan Vasu Syncfusion Team November 10, 2016 03:49 AM UTC

  
Hi Andrew, 


We have checked your query and you can select single row using SfDataGrid.SelectedIndex or SfDataGrid.SelectedItem. If you want to select multiple rows, you have to use SfDataGrid.SelectedItems property. We have modified your sample to provide multiple selection. 
  

Please refer the below UG Link to know more about Selection. 



Regards, 
Srinivasan 



AN Andrew November 10, 2016 03:03 PM UTC

But, unfortunately, this is not a thing that i am looking for. I need to bring some master details' item in view.


JG Jai Ganesh S Syncfusion Team November 13, 2016 03:00 PM UTC

Hi Andrew,  
 
We cannot understand your requirement clearly. We already provide the sample for selecting DetailsViewGrid items. Now we have modified the sample for scroll to the selected items in DetailsViewDataGrid. 
 
 
Could you please check the above sample and if this is not your requirement then please share the more details about your requirement? This would be more helpful for us to analyze further. 
 
Regards, 
Jai Ganesh S 



AN Andrew November 13, 2016 03:36 PM UTC

I've just created a video. Hope it will help.

Attachment: Untitled_a919e9db.zip


SV Srinivasan Vasu Syncfusion Team November 14, 2016 12:35 PM UTC

Hi Andrew, 
 
We have checked your query and we have modified the sample based on your requirement. Now, we have modified the sample to bring the MasterDetail Item in view. 
 
Please refer the below code example. 
 
Code Example  
 
  // parent DataGrid row index 
            int parentRowIndex = 25; 
            var record = dataGrid.View.Records[dataGrid.ResolveToRecordIndex(parentRowIndex)]; 
 
  // MasterDetails View record 
            var parentindex = dataGrid.ResolveToRowIndex(record); 
 
// Bring into View the MasterDetailsView Item 
         dataGrid.ScrollInView(new RowColumnIndex(parentindex, dataGrid.GetFirstColumnIndex())); 
 
 
 
 
Could you please check the above sample and if this is not your requirement then please share the more details about your requirement? This would be more helpful for us to analyze further.  
  
Regards, 
Srinivasan 
 



AN Andrew November 14, 2016 01:02 PM UTC

I almost understand the problem. I need to bring into view the MasterDetailsView Item's child.
I found that you do practically this in this part of code:


But this works only for reqIndex == detailsViewDataGrid.View.Records.Count - 1 and only once.
If I assign reqIndex = detailsViewDataGrid.View.Records.Count / 2, it will stop working.
And just to illustrate. I click the button once:



And again:



Required row disappeared.


SV Srinivasan Vasu Syncfusion Team November 16, 2016 03:51 AM UTC

Hi Andrew,

 
We will provide workaround for your query. A support incident to track the status of this feature has been created under your account. Please log on to our support website to check for further updates 
  
Please let me know if you have any questions. 
  
Regards, 
srinivasan 



AN Andrew November 17, 2016 03:56 PM UTC

Thanks for support. The issue was resolved :)


SV Srinivasan Vasu Syncfusion Team November 17, 2016 05:59 PM UTC

Hi Andrew, 
  
Thanks for your update. 
  
Regards, 
Srinivasan 
10

Loader.
Live Chat Icon For mobile
Up arrow icon