First Time Using DataTables in MVC 4

First Time Using DataTables in MVC 4

paragpatilparagpatil Posts: 10Questions: 3Answers: 0

Hi,

I am new to DataTabels usage and trying very basic example that is documented on DataTables Getting Started Section.

Below is my MVC view,

@{
ViewBag.Title = "Index";
}

<!DOCTYPE html>
<html>
<head>
<title>JQuery DataTables/ASP.NET MVC Integration</title>

<link href="~/Content/DataTables/jquery.dataTables.min.css" rel="stylesheet" />
<script src="~/Scripts/DataTables/jquery.js"></script>
<script src="~/Scripts/DataTables/jquery.dataTables.min.js"></script>



<script type="text/javascript">

       $(function () {
           var oTable =  $("#table_id").DataTable();
       });
</script>

</head>
<body>
<table id="table_id" class="display">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1 Data 1</td>
<td>Row 1 Data 2</td>
</tr>
<tr>
<td>Row 2 Data 1</td>
<td>Row 2 Data 2</td>
</tr>
</tbody>
</table>

</body>
</html>


I have included all the necessary files

But still DataTables is not working. I am getting "Uncaught TypeError: undefined is not a function" at javascript function.

I checked it at http://live.datatables.net/zamakip/3/edit and here it is working correctly?
What can be the issue?

Regards,
Parag

Answers

  • saadmanaisaadmanai Posts: 1Questions: 0Answers: 0

    You probably have a conflict with your jquery files as you may be using more than one jquery file. Check your _Layout.cshtml page, you probably have a @scripts.render tag in there with a reference to bundles or something

This discussion has been closed.