The requirement as follows; The data from backend is stored in row data and passed to ag-grid. The numeric fields in the row data needs to be rounded to 2 digits or more based on the business need. I need to provide numeric filter that needs to filter based on rounded values.
I have attached a sample code in plunker https://plnkr.co/edit/zlNhlPmmFC2GfLfS.
{ field: 'exp',
filter: "agNumberColumnFilter",
cellRenderer: params => {
if (params.value) {
return Number(parseFloat(params.value).toFixed(2)).toLocaleString("en");
}},
filterValueGetter: params => {
if (params.data.exp) {
return Number(parseFloat(params.data.exp).toFixed(2)).toLocaleString("en");
}}
},
For example, the experience column is received as 3.765. It needs to be displayed as 3.77. I have used cellRenderer to achieve the same. It is working fine. The next step is filter needs to work when the user type in 3.77. But it is working when the user is typing the original value 3.765. So I am trying to achieve this using filterValueGetter and round the values. It is not working. I have tried options with valuegetter and filter api and it is not working. Appreciate a solution without modifying the actual json and format it in the grid using the available API