Datatable showing but none of the functions work.

Datatable showing but none of the functions work.

klatzenklatzen Posts: 2Questions: 1Answers: 0

Hello Guys!

I'm developing an application in Asp.net MVC 5 and DataTables is just what I need for my tables BUT!

After a lot of struggle, I finally managed to get the datatable options showing on my table (As seen on the pictures). None of them are working however (Search, Pagination, Sorting etc.). In my test table I have about 300 rows, but as you can see on the bottom photo it seems like DataTable doesn't recognize the rows.

In my controller I first request the rows from a mySQL database and then when they are loaded I return a view containing a table populated with the data, so I don't think that its because the document is loaded before the data is ready in the table.

This is how my jQuery function looks like:
$(document).ready(function () {
$('#myTable').DataTable({
"sPaginationType": "full_numbers"
});
});

This gets called at the end of the html document.

Unfortunately I'm developing on my local machine, so cannot link you to a demo page of my code. But ask away if you need more information!

Thanks in advance, Christian.

Answers

  • klatzenklatzen Posts: 2Questions: 1Answers: 0

    Okay, I found a solution. It turns out that adding the rows dynamically doesn't work for DataTable, so one must use some jquery / js for it to work.

This discussion has been closed.