function restoreRow(e,t){for(var a=e.fnGetData(t),n=$(">td",t),i=0,r=n.length;r>i;i++)e.fnUpdate(a[i],t,i,!1);e.fnDraw()}function editRow(e,t){var a=e.fnGetData(t),n=$(">td",t);n[0].innerHTML='<input type="text" value="'+a[0]+'">',n[1].innerHTML='<input type="text" value="'+a[1]+'">',n[2].innerHTML='<input type="text" value="'+a[2]+'">',n[3].innerHTML='<input type="text" value="'+a[3]+'">',n[4].innerHTML='<input type="text" value="'+a[4]+'">',n[5].innerHTML='<a class="edit-row" href="javascript:void(0)">Save</a>'}function saveRow(e,t){var a=$("input",t);e.fnUpdate(a[0].value,t,0,!1),e.fnUpdate(a[1].value,t,1,!1),e.fnUpdate(a[2].value,t,2,!1),e.fnUpdate(a[3].value,t,3,!1),e.fnUpdate(a[4].value,t,4,!1),e.fnUpdate('<a class="edit-row" href="javascript:void(0)">Edit</a>',t,5,!1),e.fnDraw()}$(document).ready(function(){var e=$("#datatable-editable").dataTable({sPaginationType:"full_numbers",aoColumnDefs:[{bSortable:!1,aTargets:[-2,-1]}]}),t=null;$("#add-row").click(function(a){a.preventDefault();var n=e.fnAddData(["","","","","",'<a class="edit-row" href="javascript:void(0)">Edit</a>','<a class="delete-row" href="javascript:void(0)">Delete</a>']),i=e.fnGetNodes(n[0]);editRow(e,i),t=i}),$("#datatable-editable").on("click","a.delete-row",function(t){t.preventDefault();var a=$(this).parents("tr")[0];e.fnDeleteRow(a)}),$("#datatable-editable").on("click","a.edit-row",function(a){a.preventDefault();var n=$(this).parents("tr")[0];null!==t&&t!=n?(restoreRow(e,t),editRow(e,n),t=n):t==n&&"Save"==this.innerHTML?(saveRow(e,t),t=null):(editRow(e,n),t=n)})});