Skip to content
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

AntD Table - Search textbox to filter/search in all columns #22969

Closed
1 task done
mbv401920150 opened this issue Apr 6, 2020 · 9 comments
Closed
1 task done

AntD Table - Search textbox to filter/search in all columns #22969

mbv401920150 opened this issue Apr 6, 2020 · 9 comments

Comments

@mbv401920150
Copy link

mbv401920150 commented Apr 6, 2020

  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

I previously used Material Table, and the only thing that I miss is the option to search/filter this table because the filter performs in all columns.
https://material-table.com/#/docs/features/search

What does the proposed API look like?

Have the option to enable or disable the search option based on the API (Like the Material UI Table)

@afc163
Copy link
Member

afc163 commented Apr 7, 2020

You can create your table by composing Table and Input component, or you can try https://github.com/ant-design/pro-table/

@afc163 afc163 closed this as completed Apr 7, 2020
@mbv401920150
Copy link
Author

mbv401920150 commented Apr 9, 2020

Well, the Pro-table doesn't work... but, I created a quick and easy example of how it should work...

If somebody else required inspiration... check out this code:
CodeSandBox

I will need to include more code to validate when the column is a picklist/Combobox/select option instead of plain text... but I will work on that!

@Vishnu-Das
Copy link

@mbv401920150 codeSandBox link is not active any more can you send it once more. Thanks

@mbv401920150
Copy link
Author

@mbv401920150 codeSandBox link is not active any more can you send it once more. Thanks

Seems that still working, please check again... FYI, this is the link:
https://codesandbox.io/s/basic-usage-ant-design-demo-2swep?file=/index.js

@deep-link
Copy link

This would be help you,

<Table loading={loading || dataTableLoading} pagination={{ onChange: (page, recordsPerPage) => this.paginate(page, recordsPerPage), total, defaultPageSize: 10 }} onChange={(pagination,unknown,sortedColumn,action)=>{ /*Do your remort search*/ }} filterMultiple={true} rowSelection={rowSelection} dataSource={data}>

@GokulVertex
Copy link

how to ant design table search in function components

@duanduan321
Copy link

@mbv401920150 codeSandBox link is not active any more can you send it once more. Thanks

Seems that still working, please check again... FYI, this is the link:
https://codesandbox.io/s/basic-usage-ant-design-demo-2swep?file=/index.js

this works partially, because if you have other values in the object and one of them is not in any column of your table, that is, it is not being used for some reason, and if you search for it, the filter will return true exemple. How to solve this?
image

@shihababrar
Copy link

shihababrar commented Feb 22, 2023

Those for are looking the solution using react-hook in Functional Component. Here's the codesandbox link:

https://codesandbox.io/s/antdesign-table-search-option-forked-3i1bwb?file=/index.js

@MrUsmanDev
Copy link

MrUsmanDev commented Apr 30, 2024

you can add TextBoxes in each columns like this

const columns = [
{

  title:<span className="dragHandler">Name</span>,
  dataIndex: 'name',
  key: '1',
  sorter: (a, b) => a.name.length - b.name.length,
  sortDirections: ['ascend', 'descend'],
  sortIcon: (sortDir) => {
    if (sortDir.sortOrder === 'ascend') return <CaretUpOutlined />;
    if (sortDir.sortOrder === 'descend') return <CaretDownOutlined />;
    return  <CaretUpOutlined />; // Return null if no sorting direction is set
  },
  children:[
    {
      title: <Input />,
      dataIndex: 'name',
      key: 'name',
    }
  ],
  ...getColumnSearchProps('name'),
  
  
}],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants