question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom Filter + Sort in one column

See original GitHub issue

When I define a column with cell filtering and sorting enabled, clicking the filter input triggers the sorting. Can I somehow compose the header by myself (trigger included)? I tried headerFormatter, but I think the sort function is bound to the th.sortable element itself, and I can’t access it from headerFormatter iteself.

I can’t find such an example in the Storybook. Sorting and Filtering are occouring independantly only.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
AllenFangcommented, Oct 28, 2018

@owczar1981 @victorkpublic I think if you guys use custom filter, you may need to call stopPropagation manually. to avoid the event bobble up: for example this is how react-bootstrap-table2 avoid to trigger the sort when click on default text filter:

https://github.com/react-bootstrap-table/react-bootstrap-table2/blob/master/packages/react-bootstrap-table2-filter/src/components/text.js#L75-L80

Let me know if above solution is not work for you guys. thanks

1reaction
sovanjanacommented, Oct 29, 2020

I am using customFilter with react-datepicker, and I am facing the same issue.

function DateTimeFilter(props) { const { onFilter, column } = props;

const [startDate, setStartDate] = useState();

const handleChange = (date, event) => {
    event.stopPropagation();
    setStartDate(date);
    onFilter(date);
}

return (
    <DatePicker
        dateFormat='dd/MM/yyyy'
        selected={startDate}
        onChange={handleChange}
        isClearable
    />
);

}

this is the code snippet I am using but after preventing also the sorting gets triggered

@AllenFang

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sort data in a range or table - Microsoft Support
Optionally, create a custom list: · Select a cell in the column you want to sort. · On the Data tab, in the...
Read more >
Sort data in a table - Microsoft Support
Select Home > Sort & Filter. ... Or, select Data > Sort. ... Select an option: ... Custom Sort - sorts data in...
Read more >
How to Use the Custom Sort Feature in Microsoft Excel
Select the data you want to sort. · Go to the Home tab and click Sort & Filter in the Editing section of...
Read more >
How to sort in Excel by row, column names and in custom order
The simplest way to sort your column is to click A-Z button either under the Home tab, Editing group or on the Data...
Read more >
How to Sort in Excel Rows or Columns Avoid Sort Problems
In the Editing group, click the arrow on Sort & Filter. Click Custom Order. custom sort command. In the Sort dialog box, select...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found