I have created ag-grid in reactjs and typescript it is working well. But in my one of the column it is type of date field where with the help of valueFormatter and moment I am returning fromNow().
{ headerName: "Submitted Date", field: "LastSubmittedDate", filter: 'agNumberColumnFilter', floatingFilter: true,
valueFormatter:(params: ValueFormatterParams)=>{
return params.value ? moment(params.value).fromNow() : ''
} },
Now I want to filter that column with number of days with greater than only. Can somebody help me. My full code is here
please check my stackblitz which i forked from your example.
what i did is that I just added customFilterOptions
. My solution is more Javascript oriented and less redux but i guess you can get it fixed.
this is the piece of code which i added to column to make it work and only showing greater than option to end user while filtering.
filterParams:{
filterOptions:[
'greaterThan',
{
displayKey: 'greaterThan',
displayName: 'Greater Than',
test : function(filterValue,cellValue){
let celldate = moment(cellValue);
let today = moment();
let datediff = today.diff(celldate,'days')
debugger;
return cellValue == null || datediff > filterValue;
}
}
]
},
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.