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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GetDetailsViewGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

127251 Nov 5,2016 08:23 PM UTC Nov 17,2016 05:59 PM UTC WPF 11
loading
Tags: SfDataGrid
Andrew
Asked On November 5, 2016 08:23 PM UTC

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

Srinivasan Vasu [Syncfusion]
Replied On 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 specified DetailsViewDataGrid into view, by using DetailsViewManger.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 
 


Andrew
Replied On 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

Srinivasan Vasu [Syncfusion]
Replied On 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. 
  
Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/MasterDetailsView_20151096224012.zip 

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

UG Link: https://help.syncfusion.com/wpf/sfdatagrid/selection#programmatic-selection 


Regards, 
Srinivasan 


Andrew
Replied On 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.

Jai Ganesh S [Syncfusion]
Replied On 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. 
 
Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/MasterDetailsViewDemo-589101113.zip 
 
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 


Andrew
Replied On November 13, 2016 03:36 PM UTC

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

Attachment: Untitled_a919e9db.zip

Srinivasan Vasu [Syncfusion]
Replied On 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())); 
 
 
 
Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/MasterDetailsViewDemo-207440887.zip 
 
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 
 


Andrew
Replied On 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.

Srinivasan Vasu [Syncfusion]
Replied On 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 
 
https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents
 
  
Please let me know if you have any questions. 
  
Regards, 
srinivasan 


Andrew
Replied On November 17, 2016 03:56 PM UTC

Thanks for support. The issue was resolved :)

Srinivasan Vasu [Syncfusion]
Replied On November 17, 2016 05:59 PM UTC

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;