ASP.NET MVC5 and DataTables

Thanks to Stack Overflow

In BundleConfig.cs I added the following lines:

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(

        bundles.Add(new ScriptBundle("~/bundles/datatables").Include(

In _Layout.cshtml I added the following to the head tag:

<link href="~/Content/jquery.dataTables.css" rel="stylesheet" type="text/css"/>
<link href="~/Content/jquery.dataTables_themeroller.css" rel="stylesheet" type="text/css" />

Finally, at the bottom of Index.cshtml is the call to the script:

    $(document).ready( function () {
    } );
For DataTables to work, the <thead> is compulsory and <tbody> is optional. When you are going to add the <thead> tag, its better to add the <tbody> tag also

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s