Add/Edit/Delete rows in HTML table using JQuery





If you are looking for a solution to add, delete and update the html table content at client side, you can refer below steps of this post. I am using the jQuery, HTML and REST services languages for this post. Leave your suggestion and question down below in comment section.




Let’s get started


 


Step 1 - Jquery Files -


 


Step 2 - HTML Table


If table columns are not define and you want to add them at run time then use below HTML table structure



Otherwise, you can add the column name under thead tag.





This table will be used for adding/updating the table records






Also, declare the hidden field to store the HTML table row id. Use when we perform edit and delete operation on records








Step 3- Add Data to HTML Table


As I said in the beginning of this post that I am going to use the WCF REST services to get the data from database and service returns the data in JSON format.


1.       JSON file format


[{“TeamId”:”1”,”TeamName”:”Development”},{ “TeamId”:”2”,”TeamName”:”Testing”}]


2.       Add header & data rows to html table at run time


1.       Add only data rows to the html table at run time



Step 4 – Perform Edit operation on HTML table records







Former code will populate the values to the “tblTeam” table controls and store the team id in hidden field (ItemId).


Step 5 – Perform delete operation on HTML table records







The above code will delete the row from HTML table.


Step 6 – Save the changed to the database.





Step 7 – Add/Clear Fields




Comments

Popular posts from this blog

SSIS Merge Join - Both inputs of the transformation must contain at least one sorted column, and those columns must have matching metadata SSIS

jsGrid

Add Item to SharePoint List with attachment using client object model