-
-
Notifications
You must be signed in to change notification settings - Fork 51.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Table column filter value type could be number or boolean #22277
fix: Table column filter value type could be number or boolean #22277
Conversation
Example: import React from "react";
import { Table } from "antd";
import { ColumnsType } from "antd/lib/table";
interface Order {
id: string;
processed: boolean;
status: number;
}
const columns: ColumnsType<Order> = [
{
title: "ID",
dataIndex: "id"
},
{
title: "Processed",
dataIndex: "processed",
filters: [
{ text: "Yes", value: true },
{ text: "No", value: false }
],
render: value => `${value}`,
onFilter: (value, record) => record.processed === value
},
{
title: "Status",
dataIndex: "status",
filters: [
{ text: "Created", value: 0 },
{ text: "Approved", value: 1 },
{ text: "Completed", value: 2 }
],
onFilter: (value, record) => record.status === value
}
];
const orders: Order[] = [
{
id: "1001",
processed: true,
status: 0
},
{
id: "1002",
processed: false,
status: 1
},
{
id: "1003",
processed: false,
status: 2
}
];
function App() {
return <Table<Order> columns={columns} dataSource={orders} />;
} |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit b159470:
|
Codecov Report
@@ Coverage Diff @@
## master #22277 +/- ##
==========================================
+ Coverage 97.96% 97.96% +<.01%
==========================================
Files 306 306
Lines 7043 7044 +1
Branches 1938 1893 -45
==========================================
+ Hits 6900 6901 +1
Misses 143 143
Continue to review full report at Codecov.
|
Co-Authored-By: 偏右 <afc163@gmail.com>
检查一下 ci,看看什么问题。 |
🤔 This is a ...
🔗 Related issue link
💡 Background and solution
While using TypeScript,
ColumnFilterItem
value type of Table is valid only by string.number
andboolean
types are used in many cases, so they can be ofany
type.📝 Changelog
column.filter
的value
定义可以支持string | number | boolean
☑️ Self Check before Merge