Ejemplo 1: tablas de datos agregan fila
const table =$("#yourTable").DataTable();
table.row.add(/* array or object */).draw();// or using trconst tr =$("1 2 ");
table.row.add(tr[0]).draw();// you must call draw() to see your changes
Ejemplo 2: agregar filas y calcular en jquery datatable
Plaintext12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364$(document).ready(function()loadMyItems(););functionloadMyItems()var siteUrl = _spPageContextInfo.siteAbsoluteUrl;var oDataUrl = siteUrl +"link"; $.ajax( url: oDataUrl, type:"GET", dataType:"json", headers:"accept":"application/json;odata=verbose", success: mySuccHandler, error: myErrHandler );functionmySuccHandler(data)tryvar dataTableExample =$('#table_id').DataTable();if(dataTableExample !='undefined') dataTableExample.destroy(); dataTableExample =$('#table_id').DataTable( scrollY:770,"order":[[2,"asc"]],"pageLength":50,"aaData": data.d.results,"aoColumns":["mData":"EditLink","render":function(EditLink)return'EditLink+'');">Edit';,"mData":"Title","mData":"StartDate","mData":"Planned_x0020_Date","mData":"Days_x0020_of_x0020_delay","mData":"Days_x0020_Left","mData":"Reason_x0020_for_x0020_Late_x002","render":function(data, type, full, meta)if(!data)var returnText ="";elsevar returnText = data.results;return returnText;]);catch(e)alert(e.message);functionmyErrHandler(data, errCode, errMessage)alert("Error: "+ errMessage);
valoraciones y comentarios
¡Haz clic para puntuar esta entrada!
(Votos: 2 Promedio: 4)