Set gridrows to a model property list

Hey!

I have a ViewModel which has a List property:
The ViewModel:

The property ViewModel:

I managed to load the subitems to a grid and I would like to send the selected rows to the controller.


Is it possible anyhow? I used to use for this kind of problems the name html attribute like name="Something[i].Anything"

Please let me know if you need more information or the source code. 

Thank you in advance!

Ferenc


2 Replies

FE Ferenc May 30, 2022 07:43 PM UTC

In the meantime I've found a workaround to my problem. I've created templates for the grid columns with the proper input and name attributes:


It works properly but please if you know an easier / nicer method let me know, thanks! :)



JC Joseph Christ Nithin Issack Syncfusion Team May 31, 2022 02:04 PM UTC

Hi Ferenc,


  Greetings from the Syncfusion support.


  Based on your requirement, you want to get the selected rows in the controller. You can get the selected row using the method ‘getSelectedRows’  which returns the row elements or if you want to access the data of the selected rows you can use the `getSelectedRecords`.


API:

https://ej2.syncfusion.com/documentation/api/grid/#getselectedrecords
https://ej2.syncfusion.com/documentation/api/grid/#getselectedrows


If the above does not satisfy your requirement, please share the details so that we may be able to assist you in a better way.


  • You have used templates for the columns, please ensure that you have used template only for getting the data in the selected rows?
  • Please explain your requirement in detail.
  • Please share a video demo for your requirement.
  • Please share a simple sample for further validation.
  • Please share the Syncfusion package version you are using.


Please get back to us for further details.


Regards,

Joseph I.


Loader.
Up arrow icon