Introduction
- Dynamically append the rows to the table with JQuery.
- Here we have an example that show the event details. Against each event there may be a number of tickets generated for an event.
- The tickets generated have to be added in the table as a row, containing Ticket number, price, edit, and save button for save.
- Edit and Delete buttons also given for their respective operations. They also giving dynamic editing and deleting features.
- On click of save data will be posted on server.
Start writing HTML Code
- Create basic layout of the page.
- Add texboxes, button for appending row dynamically and save button for posting the data on the server.
- Add a table with header row only. In this table we have to append rows by clicking on ticket button.
Start writing script for dynamic crud of row
- addRow function appends the row in the table containing textbox ,label,button for save with seprate id of each row and each control in a row.
- SaveTicket function save the current row in which the click event is fired and adds the edit and delete button in the row inplace of save.
- row id is passed to each function to verify that click event is performed from which row.
- EditTicket function again edit the current row and show textboxes in place of labels with update button to update the data in a row.
- UpdateTicket update the data and show the edit and delete button with all the data in labels.
- DeleteTicket delete the row from the table.
- Include the script in head tag of html page.
Reference Articles for AngularJS: