开发者

Why is my Date sorting alphabetical instead of newest to oldest. Jquery DataTables

开发者 https://www.devze.com 2023-02-23 01:12 出处:网络
I have a datatable and my date is sorted at the beginning from newest to oldest. When I click on the sort tab it i开发者_StackOverflows sorting it by alphabet.How could I go about sorting it from newe

I have a datatable and my date is sorted at the beginning from newest to oldest. When I click on the sort tab it i开发者_StackOverflows sorting it by alphabet. How could I go about sorting it from newest to oldest when I click the sort. I've tried aoColumns and asSorting and ao ColumnDefs and I am stumped.

I sort my date by descending in my controller.

var coupons = couponRepository.GetList(c => c.TenantId == tenant.ID).OrderByDescending(c => c.RedemptionDate);

My initialization code:

$(document).ready(function () {
        //Grid
        $(".gridView").dataTable({
         "bJQueryUI": true,
         "sPaginationType": "full_numbers",
         "aoColumnDefs": [
               { "asSorting": ["desc", "asc"], "aTargets": [4] }
         ]
});
});

Thanks :)


Based on your code I assume you're using the code located at http://datatables.net if that's the case I suggest you check out the plugins listed http://www.datatables.net/plug-ins/sorting There's a plugin to allow for sorting by dates.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号