DataTables warning: table id=table_id -

DataTables warning: table id=table_id -

erumerum Posts: 9Questions: 4Answers: 0
edited January 2018 in Free community support

i m getting subjected error when run code

**DataTables warning: table id=table_id - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3**

@model IEnumerable<CallCenterCRM.Models.EmpDeptViewModel>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<script type="text/javascript">
    $(document).ready(function () {
        $('#table_id').dataTable({
            "pagingType": "full_numbers",

            "scrollY": "400px"
        });
    });
</script>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table id="table_id"       class="table table-condensed table-striped table-hover">
    <thead>
        <tr>

            <th>
                @Html.DisplayNameFor(model => model.Department)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Abbreviation)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.prefix)
            </th>
            <th>
                @Html.DisplayName("Department Incharge")
            </th>
            <th></th>
        </tr>
        </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>

                <td>
                    @Html.DisplayFor(modelItem => item.Department)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Abbreviation)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.prefix)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.SelectedEmployee)
                </td>
                <td>
                    @*@Html.ActionLink("Edit", "Edit", new { id=item.DepartmentID }) |
                        @Html.ActionLink("Details", "Details", new { id=item.DepartmentID }) |
                        @Html.ActionLink("Delete", "Delete", new { id=item.DepartmentID })*@
                </td>
            </tr>
        }
    </tbody>

</table>
@section scripts{
    <script>
        $(document).ready(function () {
            $("#table_id").DataTable({
                "pagingType": "full_numbers",
            });
        });

    </script>

}

EDIT: Update post to format code using Markdown.

Answers

This discussion has been closed.