﻿@using Mvc.JQuery.Datatables
@model DataTableVm
<table id="@Model.Id" class="display" >
    <thead>
        <tr>
            @foreach (var column in Model.Columns)
            {
                <th>@column</th>
            }
        </tr>
        <tr>
            @foreach (var column in Model.Columns)
            {
                <th>@column</th>
            }
        </tr>
    </thead>
    <tbody>
        <tr>
            <td colspan="5" class="dataTables_empty">
                Loading data from server
            </td>
        </tr>
    </tbody>
</table>
<script type="text/javascript">
    $(document).ready(function () {
        var $table = $('#@Model.Id');
        var dt = $table.dataTable({
            "bProcessing": true,
            "bStateSave": true,
            "bServerSide": true,
            "sAjaxSource": "@Html.Raw(Model.AjaxUrl)",
            "fnServerData": function (sSource, aoData, fnCallback) {
                $.ajax({
                    "dataType": 'json',
                    "type": "POST",
                    "url": sSource,
                    "data": aoData,
                    "success": fnCallback
                });
            }
        });
        @if(Model.ColumnFilter){
            @:dt.columnFilter({ sPlaceHolder: "head:before" });
        }
    });
</script>

﻿@using Mvc.JQuery.Datatables
@model DataTableVm
<table id="@Model.Id" class="display" >
    <thead>
        <tr>
            @foreach (var column in Model.Columns)
            {
                <th>@column</th>
            }
        </tr>
        @if (Model.ColumnFilter)
        {
            <tr>
                @foreach (var column in Model.Columns)
                {
                    <th>@column</th>
                }
            </tr>
        }
    </thead>
    <tbody>
        <tr>
            <td colspan="5" class="dataTables_empty">
                Loading data from server
            </td>
        </tr>
    </tbody>
</table>
<script type="text/javascript">
    $(document).ready(function () {
        var $table = $('#@Model.Id');
        var dt = $table.dataTable({
            "bProcessing": true,
            "bStateSave": true,
            "bServerSide": true,
            "sAjaxSource": "@Html.Raw(Model.AjaxUrl)",
            "fnServerData": function (sSource, aoData, fnCallback) {
                $.ajax({
                    "dataType": 'json',
                    "type": "POST",
                    "url": sSource,
                    "data": aoData,
                    "success": fnCallback
                });
            }
        });
        @if(Model.ColumnFilter){
            @:dt.columnFilter({ sPlaceHolder: "head:before" });
        }
    });
</script>

Hide row when ColumnFilter is false
Hide row when ColumnFilter is false
