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; } |
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