admin管理员组文章数量:1125573
I am using ag-grid-community 33.0.3
and ag-grid-angular 33.0.3
I have code that sets column filter using the api
applyNumberFilter(operation: OperationsFormValue) {
const filterModel = this.params.api.getFilterModel();
const gridFilter: NumberFilterModel = {
filterType: "number",
type: operation.operator,
filter: operation.value1,
filterTo: operation.value2,
};
filterModel[this.colId] = gridFilter;
console.log("Set", filterModel);
this.params.api.setFilterModel({ ...filterModel });
console.log("Get", this.params.api.getFilterModel());
}
the output in the console looks like this
Set {"time_duration":{"filterType":"number","type":"equals","filter":55,"filterTo":null}}
Get {"time_duration":{"filterType":"text","type":"equals","filter":"55"}}
Any ideas why it is being changed to text filter
In my defaultColDef i have
cellDataType: false
I am using ag-grid-community 33.0.3
and ag-grid-angular 33.0.3
I have code that sets column filter using the api
applyNumberFilter(operation: OperationsFormValue) {
const filterModel = this.params.api.getFilterModel();
const gridFilter: NumberFilterModel = {
filterType: "number",
type: operation.operator,
filter: operation.value1,
filterTo: operation.value2,
};
filterModel[this.colId] = gridFilter;
console.log("Set", filterModel);
this.params.api.setFilterModel({ ...filterModel });
console.log("Get", this.params.api.getFilterModel());
}
the output in the console looks like this
Set {"time_duration":{"filterType":"number","type":"equals","filter":55,"filterTo":null}}
Get {"time_duration":{"filterType":"text","type":"equals","filter":"55"}}
Any ideas why it is being changed to text filter
In my defaultColDef i have
cellDataType: false
Share
Improve this question
asked 2 days ago
DaleDale
4103 silver badges16 bronze badges
1 Answer
Reset to default 0If the column you are applying the number filter to does not have cellDataType set, then AG Grid does not know the type of data in that column -- cellDataType=false in your defaultColDef stops AG Grid from inferring the data types in all columns. AG Grid defaults the filter type to text if it doesn't know the data type of the column it's being applied to.
Confirmed here https://codesandbox.io/p/sandbox/d7pkv4. Then click the "Set Custom Filter" button to see the filter model printed to the console for the "age" column. You'll see it prints with filterType: "text" even though I defined filterType: "number." Then either add cellDataType: "number" to the age column definition or remove cellDataType: false from the defaultColDef. You'll see the printed filter model has filterType: "number" as defined.
本文标签: ag gridSetting AGGrid number filter saves it as a text filterStack Overflow
版权声明:本文标题:ag grid - Setting AGGrid number filter saves it as a text filter - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736631018a1945778.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论