I'm using the ag-grid component in my code and would like to ensure that date columns are formatted according to the customers needs when exported as CSV. A default format for a js Date object is used currently. The code can be found here:
https://github.com/ceolter/ag-grid/blob/master/src/ts/csvCreator.ts
I could make the following change to the code directly, but this is obviously bad practice. I'm fairly new to JavaScript and was wondering if there is a standard way to extend/override functionality in a library like this.
Proposed change (Note this shows the change I made to the js version not the github version which uses ts):
--- Common/scripts/agGrid/ag-grid.js (revision b0e7d54e61e6371b0cab94428cb4329f9f62db11)
+++ Common/scripts/agGrid/ag-grid.js (revision )
@@ -1848,7 +1848,11 @@
+ var exportDateAs = function(dt){if (dt instanceof Date)
+ return dt.getFullYear() + "/" + (dt.getMonth()+1) + "/" + dt.getDate();
+ };
@@ -1883,6 +1887,9 @@
+ if (valueForCell instanceof Date){
+ valueForCell = exportDateAs(valueForCell);
+ }