Need help posting grid selections to server controller

3 posts, 0 answers
  1. Therese
    Therese avatar
    2 posts
    Member since:
    Jun 2019

    Posted 05 Nov 2019 Link to this post

    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. Therese
    Therese avatar
    2 posts
    Member since:
    Jun 2019

    Posted 05 Nov 2019 in reply to Therese Link to this post

    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?

  3. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2497 posts

    Posted 07 Nov 2019 Link to this post

    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.
Back to Top