javascript - DataTable not working -
i want use datatable plugin add paging, sorting , filtering table.
this layout view:
<!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>@viewbag.title - asp.net mvc application</title> <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" /> <meta name="viewport" content="width=device-width" /> @styles.render("~/content/css") <link href="~/content/bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="~/content/datatables/css/jquery.datatables.min.css" rel="stylesheet" type="text/css" /> @scripts.render("~/bundles/modernizr") </head> <body> <header> <div class="content-wrapper"> </div> </header> <div id="body"> @rendersection("featured", required: false) <section class="content-wrapper main-content clear-fix"> @renderbody() </section> </div> <footer> <div class="content-wrapper"> <div class="float-left"> <p>© @datetime.now.year - asp.net mvc application</p> </div> </div> </footer> @scripts.render("~/bundles/jquery") <script src="jquery-1.9.1.min.js"></script> <script src="bootstrap.min.js"></script> <script src="jquery.datatables.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $("#p_table").datatable(); }); </script> @rendersection("scripts", required: false) </body> </html>
this table in page view:
<table id="p_table" class="table table-responsive table-bordered table-striped table-hover"> <thead> <tr> <th>@html.displaynamefor(model => model.id)</th> <th>@html.displaynamefor(model => model.first_name)</th> <th>@html.displaynamefor(model => model.last_name)</th> <th>@html.displaynamefor(model => model.gender)</th> </tr> </thead> <tbody> @foreach (var item in model) { <tr> <td> @html.displayfor(modelitem => item.id) </td> <td> @html.displayfor(modelitem => item.first_name) </td> <td> @html.displayfor(modelitem => item.last_name) </td> <td> @html.displayfor(modelitem => item.gender) </td> </tr> } </tbody> </table>
i have added javascript files , stylesheets successfully, datatable effect isn't applied. using mvc4.
please help.
Comments
Post a Comment