Using Datatables with MVC5

Using Datatables with MVC5

VantasStriderVantasStrider Posts: 2Questions: 1Answers: 0
edited December 2016 in Free community support

Hi guys,

I'm trying to put together an intranet site using MVC5 that makes use of datatables but I'm having issues getting it working. As I have multiple views using tables, I'm including the following in the body of my _layout.cshtml file:

`    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    <link rel="stylesheet" type="text/css" href="DataTables/datatables.min.css" />
    <script type="text/javascript" src="DataTables/datatables.min.js"></script>
    @RenderSection("scripts", required: false)`

I then declare the table in my view with:

`<script>
    $(document).ready(function() {
        $('#Index').DataTable();
    } );
</script>`

The bootstrap formatting appears to be working as intended but I'm not getting any of the Datatables functionality - searchbar/orderable columns/etc. As best I can tell it's not being applied at all but I'm also receiving no errors.
What hideously basic step am I missing? I'm afraid I'm only learning front end webdev so please forgive my foolishness.

Answers

  • VantasStriderVantasStrider Posts: 2Questions: 1Answers: 0

    Solved the issue, by moving the jquery and datatable scripts to the header of _Layout began using datatables properly.

This discussion has been closed.