sort based on array string values
sort based on array string values
itsmesri
Posts: 9Questions: 3Answers: 0
I need to sort datatable based on string array. Datatable "Officer Position" column need to sort like array order. example first row "president" 2nd row "Vice President", etc.
var roleArray = ["President", "Vice President", "Membership Chair", "Secretary", "Treasurer", "Member"];
addTable.row.add([
searchedItem.FirstName,
searchedItem.LastName,
searchedItem.Id,
tmpV,
searchedItem.DegreeLevel,
searchedItem.DegreeProgram,
'<button type="button" data_uid="' + searchedItem.Id + '" name="deleteRowBtn" class="btn btn-primary" >Delete</button>',
getOrderNum(tmpV)
]).draw(false);
This discussion has been closed.
Answers
Try the enum plugin. I believe all you need to do is pass the array in the order you want it sorted.
Kevin
i tried not updating anything
It works here:
http://live.datatables.net/juqivale/1/edit
Did you load the
enum.js
?Maybe you can update my example to show the issue you are having.
Kevin
http://live.datatables.net/juqivale/2/edit
Please see your example that I updated. Order suppose to show "President" - On top , "Vice President" - next, "Membership Chair", "Secretary", "Treasurer", "Member" - last to show...
Seems to work when I sort the Position column. Does it not work for you?
Kevin
oops .. Yes. I did not try that way. How should I set sort position column by default?
Use the
order
option to set the initial order.Kevin
Works perfect!!! Thank you!1