Post Spring Form containing Kendo Grid as part of form

4 posts, 0 answers
  1. Aastha
    Aastha avatar
    4 posts
    Member since:
    Feb 2016

    Posted 06 Jun Link to this post

    I am working on a Spring MVC project. I have a simple JSP form that, along with other elements, needs to get some data from the user in a Grid and submit this data as part of the form to the controller. Using the Kendo JSP wrappers(kendo:dataSource-transport-create, kendo:dataSource-transport-update) I am able to add new data, edit data and send it from a blank grid to the controller. But I am not sure how to post this data as part of the form and not just a standalone grid.
  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 08 Jun Link to this post

    Hello Aastha,

    Generally speaking, forms include the values of successful controls only. That being said, you can submit the Grid values by using templates to render hidden input elements that have the same value as the corresponding cell. For example: 
    <kendo:grid-column title="FirstName" field="FirstName" template="#=FirstName# <input type='hidden' value='#=FirstName#' />" />


    Regards,
    Alexander Popov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. UI for ASP.NET AJAX banner
  4. Aastha
    Aastha avatar
    4 posts
    Member since:
    Feb 2016

    Posted 08 Jun Link to this post

    Thank you Alexander for the help. I tried using the template like you said but I am not sure once I submit the form with the grid what type of data I should expect my controller to receive. I am aware that if using the normal grid Save (transport-create) I will receive something like ArrayList<Map<String, Object>> models as the response body but this does not work when using the template like you suggested. I don't have a lot of experience with templates so I am attaching the JSP file so you could have a look at it. Please let me know what is wrong and what should be the arguments of my controller method that receives data from this form/grid.

    Also, is it possible to use this grid to somehow work with the Spring <form:form> tag and submit the grid data as part of that form.

  5. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 10 Jun Link to this post

    Hi Aastha,

    Handling the request on the server is a general JSP / Springs task and is not directly related to Kendo UI. As mentioned previously, the Grid itself cannot be submitted as part of form, unless it uses a column templates that renders some input elements. There is an ASP.NET MVC project that illustrates how thi behavior could be achieved. I would recommend checking the template here.

    Regards,
    Alexander Popov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
UI for ASP.NET AJAX banner