Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to align form fields within a table for inline editing?
    primarykey
    data
    text
    <p>I am developing a webapp using Spring, jsp, javascript, jquery.</p> <p>I display a table using datatables. When I click on a table row I want it to change all fields to an inline edit inputs, selects etc. In addition I want to show some extra input fields in the next row and a save button.</p> <p>Now I see several ways of doing this. I am not sure which one to take.</p> <ol> <li><p>I can get a handle to selected row and then iterate over the td and transform them to input/select fields. I can then insert an extra row for the new fields and the save button. I don't see this as a clean solution. I will have to issue a Post manually instead of using the Spring ModelAttribute binding for the form. (Can I still use ModelAttribute here?)</p></li> <li><p>I can create an edit form in a jsp file which looks like:</p> <p><code>&lt;form:form action="" commandName=""&gt; &lt;td&gt; &lt;input ... &gt; &lt;/td&gt; &lt;td&gt; &lt;select ... &gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;label&gt; &lt;input new field&gt; &lt;/td&gt; &lt;td&gt; &lt;button&gt; &lt;/td&gt; &lt;/tr&gt;</code></p></li> </ol> <p>Note I do not have a beginning in a jsp file as I plan to reuse the tr from the existing row in the table. This way I would be able to have a clean form and also use the update method I have already written which binds the form to a Java class. Also I do not have to bother about the alignment of input fields with the column names.</p> <p>The generated html looks like ... </p> <p>The problem with this approach is the placement of form element in the html causes the entire form to be cramped into one cell of the table which does not look good and messes up the whole layout. Is there a way out? Should I just replace the contents of the table with a having a colspan and then put divs inside this element and fine tune the css to ensure that the input fields align with the column names in the table?</p> <p><img src="https://i.stack.imgur.com/u0hdy.png" alt="Image showing the bad alignment"></p> <p>Is there a better solution you can suggest? In case the question is not very clear I can fill in more details.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload