Ramco Ramco

Ramco Ramco

  • 462
  • 2.8k
  • 398.5k

Render in Jquery DataTable

May 31 2021 2:03 AM
Hi
 
How the below 2 lines works. Secondly how to call function on click of Edit
 
{
"render": function (data, type, full, meta)
{ return '<a class="fa fa-pencil" href="#' + full.Id + '"></span></a>'; }
},
{
data: null, render: function (data, type, row) {
return "<a href='#' class='fa fa-trash' onclick=Delete('" + row.Id + "'); ></a>";
}
},
  1. $(document).ready(function () {  
  2. //loadData();  
  3. $("#tblLocation").dataTable({  
  4. ajax: {  
  5. type: "get",  
  6. url: "/Location/List",  
  7. dataType: "json",  
  8. dataSrc: ""  
  9. },  
  10. paging: true,  
  11. sort: true,  
  12. pageLength: 10,  
  13. searching: true,  
  14. columns: [  
  15. 'data''Id'"autoWidth"true },  
  16. 'data''Description'"autoWidth"true },  
  17. 'data''IsActive'"autoWidth"true },  
  18. {  
  19. "render"function (data, type, full, meta)  
  20. return '<a class="fa fa-pencil" href="#' + full.Id + '"></span></a>'; }  
  21. },  
  22. {  
  23. data: null, render: function (data, type, row) {  
  24. return "<a href='#' class='fa fa-trash' onclick=Delete('" + row.Id + "'); ></a>";  
  25. }  
  26. },  
  27. ]  
  28. });  
  29. $('body').on('click''[id*=btnEdit]'function () {  
  30. var data = $(this).parents('tr').find('td');  
  31. var id = data.eq(0).html();  
  32. var description = data.eq(1).html();  
  33. $('[id*=txtId]').val(id);  
  34. $('[id*=txtDescription]').val(description);  
  35. $("#btnAdd").hide();  
  36. $(".modal-title").html("Update");  
  37. $("#btnUpdate").show();  
  38. $('#myModal').modal("show");  
  39. });  
  40. });  
Thanks

Answers (2)