Holt59 / datatable

Javascript Plugin for data tables creation
http://holt59.github.io/datatable/
MIT License
107 stars 42 forks source link

Sort is not working #9

Closed lexfernandez closed 9 years ago

lexfernandez commented 9 years ago

This is my code:

I include the libraries:

and then I created the datatable like this:

$('#MyTable').datatable({
                data: filterList,
                pageSize: itemsPerPage,
                sort:'*',
                lineFormat: function (id, data) {
                    var res = $('<tr></tr>');
                    for (var key in data) {
                        if (key != "GroupId" && key != "GroupName"  && key != "Number")
                            if(key==="Name")
                                res.append('<td><a href="/Project/Details/'+ data['Id'] +'">' + data[key] + '</a></td>');
                            else
                                res.append('<td>' + data[key] + '</td>');
                    }
                    $(res).attr('id', data['Id']);
                    $(res).dblclick(function () {
                        window.location.href = "/Project/Details/" + $(this).attr('id');
                    });
                    return res;
                },
                pagingDivSelector: '#projectPaging',
                pagingNumberOfPages: 10
            });

Can you please tell me what am I doing wrong? the datable is created and the arrows to sort the table are shown but when you click on it it just do nothing.

Thanks, Alex Fernandez

lexfernandez commented 9 years ago

Forget about it I just needed to add the data-sort="key" with the key to the table header column to be sorted.

Thanks