I have a tricky dynamic table built from a model that I did not want to fashion in the controller so wanted to just download the table as shown. This Jquery/Javascript solution allowed me to do just that. Using a button on the page id='export' and using a table on the page id='tblExport' We add an event listener for the button - I have declared everything explicitly but could probably have shortened some references to objects.   //For the Csv Export const toCsv = function (table) {     // Query all rows     var data = "" ;     var tableData = [];     var rows = $ ( " table tr " );     rows. each ( function (index, row) {         var rowData = [];         $ (row). find ( " th , td " ). each ( function (index, column) {             rowData. push (column. innerText );         });         tableData. push (rowData. join ( "," ));     });     data += tableData. join ( " \n " );     return data; }; const download = function (te...
 
Comments