How to Install Lodash through Yarn for React

You can install lodash through yarn as follows: Step 1 – Install Lodash to get the Library yarn add lodash Step 2 – Get the Typescript info yarn add --dev @types/lodash

May 19, 2022 · 1 min · 31 words · Andrew

Fixing: ImmutableService requires getRowNodeId() callback to be implemented, your row data need IDs

If you have gotten this error before, then you have been trying to implement a rowData mapping onto Ag-Grid.. and failed! ImmutableService requires getRowNodeId() callback to be implemented, your row data need IDs How to fix the ‘Your row data need IDs’ error The good thing, is that it’s actually quite an easy fix: Make sure that you have implemented the getRowNodeId function to return an actual id: this.getRowNodeId = function(data) { return data....

June 13, 2021 · 1 min · 143 words · Andrew

Automatically Resize All Columns to Fit in Ag-Grid

If you have an Ag-Grid, and want to automatically resize all the columns to fit the width of the viewport, you can use this hack. The implementation /** * resizes the columns to fit the width of the grid * @param allowShrink if false, columns will NOT be resized when there is no "empty" horizontal space * https://stackoverflow.com/questions/55587083/ag-grid-sizecolumnstofit-only-when-there-is-space-available-in-the-total-grid-wi#answer-60753786 */ public resizeColumnsToFit(allowShrink = true) { if (this.gridApi) { if (allowShrink) { this....

June 6, 2021 · 1 min · 213 words · Andrew

How to Get All Rows in Ag-Grid

The easiest way to get the content of all rows’ data, back into a Javascript/Typescript array, is as follows. Simply create a blank array, then loop through the rows of the grid and append each row to the array. getAllRows() { let rowData = []; this.gridApi.forEachNode(node => rowData.push(node.data)); return rowData; }

June 5, 2021 · 1 min · 51 words · Andrew

How to Download a CSV file using Javascript

Ever wanted to generate a CSV (comma separated values) file directly from the browser, using Javascript? Instead of going to the server.. Look no further! Create a function to download a csv file function downloadCsv(csvData: string, filename: string) { const blob = new Blob(['\ufeff' + csvData], { type: 'text/csv;charset=utf-8;' }); const dwldLink = document.createElement("a"); const url = URL.createObjectURL(blob); const isSafariBrowser = navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Chrome') === -1; //if Safari open in new window to save file with random filename....

April 29, 2021 · 1 min · 130 words · Andrew

How to Programmatically Filter ag-Grid Columns in Angular

You can easily control the column filtering in ag-Grid by using the getFilterInstance and setModel methods associated to the column you need filtering. Once done, remember to call onFilterChanged to apply your changes. // a list of all your items you want to filter // make sure to create a list of strings // a list of numbers won't work const listOfItems = data.map((row) => row.ComeColumnItem.toString()) // get the filter instance per column const filterInstance = this....

January 27, 2021 · 1 min · 113 words · Andrew