modify sort feature on column
modify sort feature on column
jschroeder7
Posts: 22Questions: 11Answers: 0
Is it possible to modify/define what is sorted on the sort feature here in data-column-index="2" "bookmark/topic"?
I would like to sort by bookmark or topic.
For example, Topic 1 is "topic" and so is "mind", but Galatians 5:1 NKJV is a bookmark.
Both of these have been merged into one column:
bookmark.reference
topic.name
Answers
There are a few options that come to mind:
topic
orbookmark
. Usecolumns.visible
to hide the column. Usecolumns.orderData
to order the table by the hidden column followed by the Bookmark/Topic column when the user sorts the Bookmark/Topic column.sort
process.Option 1 might be the easiest. Options 2 and 3 would need a way to determine if the data is a topic or bookmark.
If you need help with these please provide a simple test case with an example of your data so we can collaborate on the code.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
@kthorngren
Thank you for your reply. Is this a possible 4th option? Per my snapshots attached? I was able to get a dropdown box there. However, it disappears when I start to search for something. And it doesn't have logic to it.
I put this code into accomplish the dropdown box.
Oh, I thought in your first post you were asking about sorting. This example shows a technique you can use to add your select list into the Datatables toolbar.
I would probably go with the first option with the hidden column but you don't need to worry about the
columns.orderData
. Create a change event handler for the select options. In the event handler usecolumn().search()
to search the hidden column which will contain eithertopic
orbookmark
.See this example to get an idea.
Kevin