GridTappedCommand - how to get the row data from the command

Hi there,

I am creating a Xamarin application using the data grid and a MVVM design. I am using the GridTappedCommand to send the event to the viewmodel . Although it works, I cannot seem to get the rowdata to the command in the viewmodel. 

I cannot find an example that in your docs or forums or if I do they seem to be out of date. 

Thanks very much

Dean

5 Replies

MK Muthu Kumaran Gnanavinayagam Syncfusion Team March 11, 2020 01:25 PM UTC

Hi Dean, 
 
We have analyzed the reported query “Need for tapped row data in GridTappedCommand” at our end. We would like to let you know that you can get the value of tapped row data from SfDataGrid.GridTappedEventArgs which is held as parameter in Execute and CanExecute methods as like below.  
 
Code Example: 
public void Execute(object parameter) 
{ 
  var eventArgs = parameter as GridTappedEventArgs; 
  var rowData = eventArgs.RowData; 
  var rowColumnIndex = eventArgs.RowColumnIndex; 
} 
 
 
We have updated our UG documentation to get the tapped item row data and it will come to live on tomorrow. Please find the sample and documentation regarding this in UG link below. 
 
 
Please let us know if you require further assistance. 
 
Regards, 
G.Muthu kumaran. 



MK Muthu Kumaran Gnanavinayagam Syncfusion Team March 12, 2020 01:54 PM UTC

Hi Dean,

The changes are in live now, please check the below UG link, 

https://help.syncfusion.com/xamarin/datagrid/grid-events#gridtapped-command
 

Regards,
 
G.Muthu kumaran. 



EV Enzo Varenna April 28, 2020 10:14 AM UTC

Hi,
how can I retrieve data from the "rowData" variable?

During debugging I see the data, but I have not the possibility to access it.
For more details, you can see the attached image


Many thanks.

Regards
Alessio

Attachment: Image_22302c3d.zip


EV Enzo Varenna replied to Enzo Varenna April 28, 2020 10:40 AM UTC

Hi,
how can I retrieve data from the "rowData" variable?

During debugging I see the data, but I have not the possibility to access it.
For more details, you can see the attached image


Many thanks.

Regards
Alessio

Attachment: Image_22302c3d.zip

I solved it like this:


var eventArgs = parameter as GridTappedEventArgs;
var rowData = eventArgs.RowData;
var rowColumnIndex = eventArgs.RowColumnIndex;

Models.OrderInfo test = rowData as Models.OrderInfo;
string sMessage = "You tapped Row " + test.Articolo.ToString();
Application.Current.MainPage.DisplayAlert("Alert", sMessage, "OK");


KK Karthikraja Kalaimani Syncfusion Team April 29, 2020 01:20 PM UTC

Hi Enzo,

Thanks for the update.

We glad to know that your requirement has resolved at your end. Please let us know if you have any further queries on this. We are happy to help you.

Regards,
Karthik Raja 


Loader.
Up arrow icon