This is a migrated thread and some comments may be shown as answers.

Need help posting grid selections to server controller

2 Answers 219 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Therese
Top achievements
Rank 1
Therese asked on 06 Nov 2019, 12:52 AM

Hello,

I am new to using the Grid and need a little help.

I have a ViewModel for my page, for brevity's sake, say the model has an EventName for display, and a List of EventRegistrations, and a couple of text boxes to capture data.  Using Razor on the view.

I am populating the grid in an Ajax call - but I am not updating any of the grid records.  Can I populate it from the ViewModel when the page loads? 

Secondly... I am using the grid to add a checkbox to each row.  I want to be able to access these selected values server-side and I do not know how to do this so that I can HttpPost to my controller all of the grid rows with the selected rows along with the couple of other textbox values I'll be using.  I have seen the .Columns.Select() approach and the ClientTemplate javascript approach.  

I usually depend on the ViewModel to be there in the post -- but I am not sure how to get values from the View's ViewModel and the KendoGrid.

I just need a little assistance getting in the right direction.

Thank you for assistance in advance,

Therese

2 Answers, 1 is accepted

Sort by
0
Therese
Top achievements
Rank 1
answered on 06 Nov 2019, 03:10 AM

I've gotten the Grid to populate from the ViewModel, no Ajax call.

Now when I post back to the Controller, no values from the Grid.  Not even what I populated with.

Ideas?

0
Viktor Tachev
Telerik team
answered on 07 Nov 2019, 02:13 PM

Hi Therese,

 

The Grid widget is not a form component and would not submit all data to the server out of the box. By design when editing items in the Grid only the modified records will be sent to the Controller. With that said, we have an example that illustrates how the Grid data can be submitted with a form:

https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/submit-grid-with-form

 

On a side note, if you would like more information on the different options that are available for binding the Grid you would find the articles below interesting. 

 

Let me know if you have additional queries.

 

Regards,
Viktor Tachev
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Therese
Top achievements
Rank 1
Answers by
Therese
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or