Sort only when sort icon is clicked, not when whole column header is clicked
See original GitHub issueI 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:
- Created 4 years ago
- Comments:5
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can move the
...getSortByToggleProps()
to whatever element you want to be able to use as the toggle.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>