بهار آموزش با تخفیف های شگفت انگیز توسینسو بهار آموزش با تخفیف های شگفت انگیز توسینسو
مانده تا پایان تخفیف
مشاهده دوره ها
0

عدم نمایش jquerydataTables

سلام

من کدهای زیر را نوشته ام

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
  
  
</head>
<body>
    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                @Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li>@Html.ActionLink("Home", "Index", "Home")</li>
                    <li>@Html.ActionLink("About", "About", "Home")</li>
                    <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
                </ul>
            </div>
        </div>
    </div>
    <div class="container body-content">
        @RenderBody()
        <hr />
        <footer>
            <p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>
        </footer>
    </div>
  
  
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>

و

@model IEnumerable<WebApplication26.Models.Form>
  
  
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href="~/Content/DataTables/css/jquery.dataTables.min.css" rel="stylesheet" />
<h2>Index</h2>
  
  
<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table class="table" id="assets-data-table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FrmName)
        </th>
        <th></th>
    </tr>
  
  
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.FrmName)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
                @Html.ActionLink("Details", "Details", new { id = item.Id }) |
                @Html.ActionLink("Delete", "Delete", new { id = item.Id })
            </td>
        </tr>
    }
  
  
</table>
@section Scripts
  
  
{
    <script src="~/Scripts/DataTables/jquery.dataTables.min.js"></script>
    <script src="~/Scripts/DataTables/dataTables.bootstrap.min.js"></script>
    <script type="text/javascript">
  
  
        $(document).ready(function () {
  
  
            $('#assets-data-table').DataTable( {
                "paging"  :     true,
                "ordering":     true,
                "info"    :     true,
                "filter"  :     true,
                "order"   :     [[ 0, "desc" ]]
            } );
        });
    </script>
}

وقتی کد

$('#assets-data-table').DataTable( {
              "paging"  :     true,
              "ordering":     true,
              "info"    :     true,
              "filter"  :     true,
              "order"   :     [[ 0, "desc" ]]
          } );

درج نکرده ام هیچ اروری وجود ندارد و البته jquerydataTables هم کار نمیکند

ولی وقتی کد بارا مینویسم

برنامه اجرا میشود ولی در Console ارور زیر رخ میدهد برای حل مشکل چکار باید کنم

سلام
من کدهای زیر را نوشته ام
<c#>
<!DOCTYPE html>
<html>
<head>
    <meta charset=utf-8 />
    <meta name=viewport content=width=device-width, initial-scale=1.0>
    <title>@ViewBag.Title - My ASP.NET Application</title>
    @Styles.Render(~/Content/css)
    @Scripts.Render(~/bundles/modernizr)
  
  
</head>
<body>
    <div class=navbar navbar-inverse navbar-fixed-top>
        <div class=container>
            <div class=navbar-header>
                <button type=button class=navbar-toggle data-toggle=collapse data-target=.navbar-collapse>
                    <span class=icon-bar></span>
                    <span class=icon-bar></span>
                    <span class=icon-bar></span>
                </button>
                @Html.ActionLink(Application name, Index, Home, new { area =  }, new { @class = navbar-brand })
            </div>
            <div class=navbar-collapse collapse>
                <ul class=nav navbar-nav>
                    <li>@Html.ActionLink(Home, Index, Home)</li>
                    <li>@Html.ActionLink(About, About, Home)</li>
                    <li>@Html.ActionLink(Contact, Contact, Home)</li>
                </ul>
            </div>
        </div>
    </div>
    <div class=container body-content>
        @RenderBody()
        <hr />
        <footer>
            <p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>
        </footer>
    </div>
  
  
    @Scripts.Render(~/bundles/jquery)
    @Scripts.Render(~/bundles/bootstrap)
    @RenderSection(scripts, required: false)
</body>
</html>
<c#>
و
<c#>
@model IEnumerable<WebApplication26.Models.Form>
  
  
@{
    ViewBag.Title = Index;
    Layout = ~/Views/Shared/_Layout.cshtml;
}
<link href=~/Content/DataTables/css/jquery.dataTables.min.css rel=stylesheet />
<h2>Index</h2>
  
  
<p>
    @Html.ActionLink(Create New, Create)
</p>
<table class=table id=assets-data-table>
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FrmName)
        </th>
        <th></th>
    </tr>
  
  
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.FrmName)
            </td>
            <td>
                @Html.ActionLink(Edit, Edit, new { id = item.Id }) |
                @Html.ActionLink(Details, Details, new { id = item.Id }) |
                @Html.ActionLink(Delete, Delete, new { id = item.Id })
            </td>
        </tr>
    }
  
  
</table>
@section Scripts
  
  
{
    <script src=~/Scripts/DataTables/jquery.dataTables.min.js></script>
    <script src=~/Scripts/DataTables/dataTables.bootstrap.min.js></script>
    <script type=text/javascript>
  
  
        $(document).ready(function () {
  
  
            $('#assets-data-table').DataTable( {
                paging  :     true,
                ordering:     true,
                info    :     true,
                filter  :     true,
                order   :     [[ 0, desc ]]
            } );
        });
    </script>
}
<c#>
وقتی کد
<js>
$('#assets-data-table').DataTable( {
              paging  :     true,
              ordering:     true,
              info    :     true,
              filter  :     true,
              order   :     [[ 0, desc ]]
          } );
<js>
درج نکرده ام هیچ اروری وجود ندارد و البته jquerydataTables هم کار نمیکند
ولی وقتی کد بارا مینویسم
برنامه اجرا میشود ولی در Console ارور زیر رخ میدهد برای حل مشکل چکار باید کنم
||https://tosinso.com/files/get/3a998ff7-f6b6-4b37-b103-80711a97b0ac||

پرسیده شده در 1396/12/22 توسط

2 پاسخ

0

مشکل عدم استفاده از تگ های thead , tbody چون نه در خود سایتش ونه منابع دیگر این نکته ذکر نشده بودش

پاسخ در 1396/12/22 توسط
1

سلام به شما دوست عزیز

برای دیتاتیبل باید جدول به صورت کامل نوشته شود یعنی از تگ های thead , tbody هم باید استفاده کنید. برای حل این خطا تست کنید ببینید که برنامه به درستی به کتابخانه های اضافه شده دسترسی دارد یا خیر.

پاسخ در 1396/12/22 توسط

پاسخ شما