代码之家  ›  专栏  ›  技术社区  ›  user9335731

未捕获的TypeError:无法设置未定义的属性“\u DT\u CellIndex”

  •  1
  • user9335731  · 技术社区  · 8 年前

    以下是我的 DataTable 。我正在尝试添加 paging searching 功能。但是,在检查时,我发现以下错误:

    未捕获的TypeError:无法设置未定义的属性“\u DT\u CellIndex”

    我的 .cshtml 代码如下:

    <thead>
        <tr>
            <th data-column-id="Id" data-type="int" data-identifier="true" hidden>ID</th>
            <th data-column-id="DeviceName">Name</th>
            <th data-column-id="DeviceType">Device Type</th>
            <th data-column-id="DeviceManufacturer">Manufacturer Name</th>
            <th data-column-id="ModelNumber">Model</th>
            <th data-column-id="DateOfPurchase">Date of Purchase</th>
            <th data-column-id="Commands">Commands</th>
        </tr>
    </thead>
    

    我的 jQuery 代码如下:

     $(document).ready(function () {
            LoadPaging();
            $('#data-table-basic').removeClass("dataTable no-footer");
            //$('table.dataTable').addClass("table table-striped table-vmiddle");
        });
    
        function LoadPaging() {
            if(@count!= 0)
            {
                var table = $('#data-table-basic').DataTable({
                    "pagination": true,
                    "bSortable": false,
                    "ordering": false,
                    "searching": true,
                    "bLengthChange": true,
                    "info": true,
                    //"lengthMenu": [6, 40, 60, 80, 100],
                    "lengthMenu":[ [10, 20, 40, 60,80,100, -1], [10, 20, 40, 60,80,100, "All"] ],
                    "pageLength": 10,
                    language: {
                        paginate: {
                            next: '',
                            previous: ''
                        }
                    }
                });
            }
        }
    

    输出上未显示搜索和分页功能 View

    1 回复  |  直到 8 年前
        1
  •  0
  •   user9335731 user9335731    8 年前

    Commands 我的中不存在列 model ,我不能提及这里。移除时 <th data-column-id="Commands">Commands</th> ,我可以看到 paging searching my上的功能 View

    以下链接帮助我找出了问题所在: DataTables.net