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.

Sort only when sort icon is clicked, not when whole column header is clicked

See original GitHub issue

I would like to have a sort icon in my header, and I would like to activate the sort only when the icon is clicked, not the whole header. As far as I can tell, for sorting, there is no way to move a column header’s onClick() handler from the entire <th> to a child element of the <th>.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
tannerlinsleycommented, Jan 9, 2020

You can move the ...getSortByToggleProps() to whatever element you want to be able to use as the toggle.

0reactions
cchintada-chikkolucommented, Sep 10, 2021

It is working for me as suggested. <thead className="bg-dark text-white"> {headerGroups.map(headerGroup => ( <tr {...headerGroup.getHeaderGroupProps()}> {headerGroup.headers.map(column => ( <th {...column.getHeaderProps()} className="justify-content-top"> {column.canFilter?<span><FaFilter onClick={ () => {column.setFilter('');setFilters({...filters, [${column.id}]: !filters[${column.id}]})}}/></span>:null} <span className="ms-5 me-5">{column.render('Header')}</span> <span> {column.isSorted ? column.isSortedDesc ? <FaSortUp {...column.getSortByToggleProps()} /> : <FaSortDown {...column.getSortByToggleProps()} /> : column.canSort?<FaSort {...column.getSortByToggleProps()} />:''} </span> <div>{column.canFilter && filters[${column.id}]? column.render("Filter") : null}</div> </th> ))} </tr> ))} </thead>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sort only when sort icon is clicked, not when whole column ...
I would like to have a sort icon in my header, and I would like to activate the sort only when the icon...
Read more >
Datatable sort only when sort icon is clicked?
causes the whole header area to be clickable for sorting. Is there a way just to enable sorting when the sort icons are...
Read more >
Datatables 1.10 sort only by cliking sort icons in th
consider I want both options, there is a server side sorting by clicking icons only, and local sorting (is done by click thead...
Read more >
Best way to prevent column sorting when icon is clicked
I have icons next to my column headers. All columns are sortable. Clicking the icon next to the header sends off an ajax...
Read more >
Bug - Column sort icon shows on click, but nothing happens
Hello Tom,. I guess that you are facing the problem described in the Sorting article: Sorting is supported only in OLAP binding scenarios....
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