Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - Edit a table row inline

I have a table with arbitrary columns and rows. This fact is irrelevant though really, all I want to do is develop a function that will turn a row (or multiple rows) into a series of text inputs containing the data in the table (or empty if no data in cell).

I can't find any examples of people explicitly doing this, so I wondered what people here think is the best way to find a solution.

like image 676
adam Avatar asked Jan 20 '09 23:01

adam


People also ask

How do I edit a table in a table using jQuery?

Inline Table Editing using jQuery Ajax PHP and MySQL. Inline editing provides an easy way to edit data in table cells. If your web application has data grid functionality, inline edit & delete is the must-have feature. The user can edit and delete content on the same page by clicking the row in the table.

How do I edit a table in PHP with inline editing?

PHP Datagrid with Inline Editing (index.php) The editable table functionality will be implemented in the index.php file. The user’s data will be retrieved from the database and listed in a table. Each table row will have an edit and delete button. On clicking the Edit button, table cells will be editable and a save button will appear on this row.

How to edit a row in HTML table?

Your users can edit a whole row of your html table or just one cell just by clicking in a cell. Below is a demo html table: At first, it would appear to be plain regular html table.

What is inline edit&delete?

Inline editing provides an easy way to edit data in table cells. If your web application has data grid functionality, inline edit & delete is the must-have feature. The user can edit and delete content on the same page by clicking the row in the table. Inline table editing provides better user experience and makes the web application user-friendly.


1 Answers

Iterate over the table cells in the rows, and replace the contents with text inputs:

function editRow(row) {
    $('td',row).each(function() {
         $(this).html('<input type="text" value="' + $(this).html() + '" />');
    });
}

You need to pass the relevant row/rows into the function obviously.

like image 148
Eran Galperin Avatar answered Oct 20 '22 00:10

Eran Galperin