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

Custom Form Around a Grid Row

5 Answers 239 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 05 Feb 2019, 10:07 PM
In our React application, we use react-advanced-form to develop forms. It's handy for quickly composing a form with validation. I am using the KendoReact Grid with inline editing. I couldn't find much documentation on GridRow or templating for it. Is there a way for me to wrap a row that is in edit mode in my own (or a third party's) <Form /> component?

5 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 05 Feb 2019, 10:41 PM

Correction.. i did find some documentation on the rowRender here: https://www.telerik.com/kendo-react-ui/components/grid/editing/editing-in-cell/

However, it doesn't seem like I will get very far if I try to return a <Form /> inside a <tr />

0
Stefan
Telerik team
answered on 06 Feb 2019, 08:01 AM
Hello, John,

The Form could be placed inside the Grid, but a couple of modifications will be needed.

1) Additional styles may be required, so the form will look nice inside the Grid tr.

2) The change events have to be handled programmatically to update the Grid data when the user types inside the form.

As we are not experts in react-advanced-form, could you please share with us an example with the Form inside the row, and how it is used.

Once we observe the specifics of this form, we will be happy to modify it in order to work nicely with the Grid.

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
John
Top achievements
Rank 1
answered on 14 Feb 2019, 02:46 AM

I think answering this question specific to react-advanced-form is needlessly complex. The same problem would exist if I were just using an html <form> element. So, say when a row is in edit mode, I want a form surrounding all the fields in a single row. Then when you click save, it submits the form for that row. Conceptually, the html that would be rendered would be something like:

1.<table>
2.  <tr>
3.    <form>
4.      <td><input type='text' id='myfield' /></td>
5.      <td><button type='submit' text='save' /></td>
6.    </form>
7.  </tr>
8.</table>

 

The obvious issue with this is that you can't have a form inside a TR. So you either have to put the form around the whole grid and handle adding/removing input elements as each row changes to edit mode, or... The solution I've gone with is to define the rowRender and have it return a <tr> with a single <td> that spans all columns. inside that <td>, i define the form, including submit and cancel buttons. Doing it that way is sort of like an inline external form (instead of a modal). The drawback to this scenario is that my inputs don't align nicely with my grid columns.

0
Stefan
Telerik team
answered on 14 Feb 2019, 07:28 AM
Hello, John,

I`m glad to hear that the form is successfully integrated with the Grid row, and thank you for sharing it with the community it is highly appreciated.

As for the styles, an idea that comes to mind is to place the elements inside a container with the same width as the columns, this should achieve a similar to the desired result:

https://stackblitz.com/edit/react-3itmyq?file=app/main.js

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
John
Top achievements
Rank 1
answered on 14 Feb 2019, 07:13 PM
That could work.. Thanks, I will experiment with that. The important thing to keep in mind with that solution is you'd want both the column widths and the <span> containers to resize simultaneously. So if you set the resizable prop on <Grid /> or if the window resizes, you'd want those to be in sync. if the columns are a static width, then it's not an issue.
Tags
General Discussions
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or