Custom Default Ordering by classname -> defaultSortASC & defaultSortDESC
Custom Default Ordering by classname -> defaultSortASC & defaultSortDESC
![Sveno](https://secure.gravatar.com/avatar/94255ed3adcf27aa26f0308d34f9e0b9/?default=https%3A%2F%2Fvanillicon.com%2F94255ed3adcf27aa26f0308d34f9e0b9_200.png&rating=g&size=120)
hey ho,
i'm a german guy and sorry for my bad english
i have one question, in my project, i use a class to set the default-ordering
myclass -> defaultSort
$('#datatables').DataTable( {
"order": [[$('th.defaultSort').index(),'desc'] ]
});
now i want to set the ordering-direction with class names
new classes: defaultSortASC & defaultSortDESC
i tried to figure out with jquery:
var order = [[$('th.defaultSort').index(),'desc'] ]
if ($(".defaultSortASC ").length ) {
order = [[$('th.defaultSortASC ').index(),'asc'] ]
}
else if ($(".defaultSortASC ").length ) {
order = [[$('th.defaultSortDESC').index(),'desc'] ]
}
$('#datatables').DataTable( {
"order": order
});
but it dont work and i think it depends on the .index()
can someone help me to solve the problem
greetings from Hamburg
This discussion has been closed.
Answers
3 Minutes after post my problem, i solved it.
i used 2 classes to handle it.
one for default order -> "defaultSort" and one for the direction -> "ASC" or "DESC"