日期为空时为什么没有数据?

时间:2015-07-29 20:10:31

标签: jquery datatables

为Jquery Datatables使用列过滤器插件时。我想按日期范围过滤。当任何日期为空时,表不显示任何数据。数据传递到页面正常,但没有显示数据:

<div class="col-lg-12">
    <table class="table table-bordered" id="activeProjects">
        <thead>
            <tr>
                <th>Project Name</th>
                <th>Project Number</th>
                <th>Market</th>
                <th>Project Type</th>
                <th>Completion Date</th>
                <th>Square Footage</th>
                <th>Architect</th>
                <th>Manager</th>

            </tr>
        </thead>
        <tfoot>
            <tr>
                <th></th>
                <th></th>
                <th></th>
                <th></th>
                <th></th>
                <th></th>
                <th></th>
                <th></th>
            </tr>
        </tfoot>
        <tbody>
            <tr ng-repeat="project in model.projects">
                <td></td>
                <td><a href></a></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        </tbody>

    </table>
    <button class="btn btn-danger" id="clear">Clear Filters</button>
</div>
<script>
    $(document).ready(function () {

        $('#activeProjects').dataTable({
            "processing": true,
            "serverSide": false,
            "bPaginate": true,
            "ajax": {
                "url": "../api/Project/GetAll/",
                "dataSrc": ""
            },
            "aoColumnDefs": [
                {
                    "aTargets": [1],
                    "mRender": function(data) {
                        return '<a href="ExistingProject?jobNumber=' + data + '">' + data + '</a>';
                    }
                }
            ],
            "sPlaceHolder": "head:before",
            "columns": [
                { "data": "ProjectName" },
                { "data": "ProjectNumber" },
                { "data": "MarketName" },
                { "data": "ProjectTypeName" },
                { "data": "DateCompleted" },
                { "data": "SquareFoot" },
                { "data": "ProjectManager" },
                { "data": "ProjectArchitect" }
            ],
            "sPaginationType": "full_numbers",
            }).columnFilter({
                aoColumns: [
                { type: "text", },
                { type: "text" }, 
                { type: "text" }, 
                { type: "text" }, 
                { type: "date-range" }, 
                { type: "text" }, 
                { type: "text" }, 
                { type: "text" } 
                ]
            });
    });

    $('#clear').click(function() {
        location.reload();
    });
</script>

如果我将过滤器类型从日期范围更改为文本,则会显示所有数据。知道为什么会这样,我怎么能告诉它是空的呢?

0 个答案:

没有答案