Select a line in the detail section of a Master-Detail datagrid
Is there a way to select an item dynamically (with line code) in the detail part of a master-detail datagrid ?
Hi MARQUANT,
Thanks for using Syncfusion Products.
You can set the value to CurrentItem as well as SelectedItem in SfDataGrid like the below code example.
Code Example[C#]:
|
void FirstDetailsViewDataGridSelectionChanged(object sender, GridSelectionChangedEventArgs e) { var OrderDetailCollection = this.AssociatedObject.DataContext as ViewModel; var CurrentItemDetails = OrderDetailCollection.OrdersDetails[2].OrderDetails[0] as OrderDetails; var SelectedItemDetails = OrderDetailCollection.OrdersDetails[3].OrderDetails[0] as OrderDetails; //Set the Specific OrderDetails to the CurrentItem/SelectedItem (e.OriginalSender as SfDataGrid).CurrentItem = CurrentItemDetails; (e.OriginalSender as SfDataGrid).SelectedItem = SelectedItemDetails; this.DetailsViewSelectedItem = (e.OriginalSender as SfDataGrid).SelectedItem; this.DetailsViewSelectedItems = (e.OriginalSender as SfDataGrid).SelectedItems; this.DetailsViewCurrentItem = (e.OriginalSender as SfDataGrid).CurrentItem; } |
We have prepared a sample for setting the values to the CurrentItem and SelectedItem of SfDataGrid using the “Behavior” concept. In this sample, we have set the particular record to SfDataGrid.CurrentItem and SfDataGrid.SelectedItem in the SelectionChanged Event and you can download that sample from the below location,
Sample Link: http://www.syncfusion.com/downloads/support/forum/120886/ze/MasterDetailsView-2006844171
Regards,
Sowndaiyan
Hi MARQUANT,
We have analyzed your query. We regret to inform you that it is not possible to set the CurrentItem / SelectedItem when performing the Add action in view model. Because it is not possible to get the exact DetailViewDataGrid in Add action. So we recommend you to use the “Behaviour” concept.
Please let us know if you require further assistance on this.
Regards,
Sowndaiyan
Hi MARQUANT,
We have analyzed your query and we have prepared the sample based upon your requirement “Set the CurrentItem / SelectedItem in add action of the DetailsViewDataGrid” . You can download the sample from the following location.
Sample Location: http://www.syncfusion.com/downloads/support/forum/120886/ze/DetailsViewDemo202407730
In this sample we have add the record into the DetailsView on a ButtonClick action using ICommand. Within this action we have set the CurrentItem / SelectedItem to the Corresponding DetailsViewDataGrid.
Please let us know if you have any other concern.
Regards,
Sowndaiyan
We have analyzed your query and we have passed the recordIndex as zero for your reference to select the first record while adding in the first DetailsViewDataGrid. You have to pass the corresponding parent recordIndex of particular DetailsViewDataGrid to GetDetailsViewGrid method. Please refer the below sample for your reference.
Sample Link: DetailsViewDemo
In the above sample, we got the recordIndex by resolving the rowIndex using SfDataGrid.ResolveToRecordIndex method. If the issue still persists, could you please modify the above sample to replicate the issue that would be more helpful for us to provide you the better solution.
Regards,
Farjana Parveen A
Thanks for the update.
Please let us know if you need further assistance.
Regards,
Sowndaiyan
- 9 Replies
- 3 Participants
-
MC MARQUANT Cédric
- Oct 25, 2015 07:48 AM UTC
- Nov 5, 2015 09:50 AM UTC