Skip to content

Instantly share code, notes, and snippets.

@im-noob
Created July 21, 2021 12:32
Show Gist options
  • Save im-noob/060d142c3c899995d68cccbcafdcde70 to your computer and use it in GitHub Desktop.
Save im-noob/060d142c3c899995d68cccbcafdcde70 to your computer and use it in GitHub Desktop.
Data table Sorting on hidden column from different related table
columns: [
{data: "check_box", mData: "check_box", orderable: false},
{data: "profile_pic_and_name", mData: "profile_pic_and_name"},
{data: "user.custom_user_id", mData: "user.custom_user_id"},
{data: "role", mData: "role"},
{data: "company_name", mData: "company_name"},
{data: "status", mData: "status"},
{data: "created_at", mData: "created_at"},
{data: "user.first_name", mData: "user.first_name","visible": false,},
],
columnDefs: [
/*it will sort table data by first_name when we click on profile_pic_and_name*/
{'orderData': [7], 'targets': [1]},
{
'targets': [7],
'visible': false,
'searchable': false
},
],
https://datatables.net/examples/basic_init/multi_col_sort.html#:~:text=DataTables%20allows%20ordering%20by%20multiple,%2C%20tertiary%20etc%20ordering%20column).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment