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

Post Spring Form containing Kendo Grid as part of form

3 Answers 244 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aastha
Top achievements
Rank 1
Aastha asked on 06 Jun 2016, 07:24 PM
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.

3 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 08 Jun 2016, 08:16 AM
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!
 
0
Aastha
Top achievements
Rank 1
answered on 08 Jun 2016, 02:02 PM

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.

0
Alexander Popov
Telerik team
answered on 10 Jun 2016, 01:18 PM
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!
 
Tags
Grid
Asked by
Aastha
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Aastha
Top achievements
Rank 1
Share this question
or