Javascript JQuery,修复了数据表中向下滚动的标题问题
我已经给出了数据表,并在向下滚动时尝试固定标题。 下面显示数据表Javascript JQuery,修复了数据表中向下滚动的标题问题,javascript,jquery,datatables,Javascript,Jquery,Datatables,我已经给出了数据表,并在向下滚动时尝试固定标题。 下面显示数据表 <table class="temp1 table table-striped dataTable mt-2 table-bordered" cellspacing="0" cellpadding="0" style="margin-bottom: 0px; margin-top: 0px;" role="grid"
<table class="temp1 table table-striped dataTable mt-2 table-bordered" cellspacing="0" cellpadding="0" style="margin-bottom: 0px; margin-top: 0px;" role="grid"
aria-describedby="user-list-page-info" id="user-list-table">
<thead id="taablehead">
<tr class="ligth" style="margin-left: 2px;">
<th>id</th>
<th>name</th>
<th>class</th>
<th> </th>
<th> </th>
<th> </th>
</tr>
</thead>
<tbody>
<tr class="ligth">
<tr class="table-info" id="row2" style="background-color: #dadbde;">
<td><input type="checkbox" class="checkbox-input"></td>
<td>10001</td>
<td>karan</td>
<td>A</td>
<td></td>
<td></td>
</tr>
<tr class="table-info" id="row3" style="background-color: #dadbde;">
<td><input type="checkbox" class="checkbox-input"></td>
<td>10002</td>
<td>john</td>
<td>B</td>
<td></td>
<td></td>
</tr>
<tr class="table-info" id="row4" style="background-color: #dadbde;">
<td><input type="checkbox" class="checkbox-input"></td>
<td>10003</td>
<td>rahul</td>
<td>C</td>
<td></td>
<td></td>
</tr>
</tr>
</tbody>
但给定的错误如
未捕获类型错误:无法设置未定义的属性“\u DT\u CellIndex”
我尝试使用datatbale js,但没有成功。您的问题是由嵌套的
$(document).ready(function() {
var table = $('.temp1').DataTable({
fixedHeader: true,
scrollX: true
});
} );
身份证件
名称
班
也许这可以帮助@CarstenLøvboAndersen先生,我已经尝试了上面给出的链接解决方案,但没有成功。无法在中设置未定义的属性通常意味着您的列定义与提供的数据不匹配。不清楚这里是否是这种情况,只是经常出现。你确实有很多打字错误,特别是@vvp45 TR作为另一个TR的直接父项是无效的,但是,在你的代码头中有很多@CarstenLøvboAndersen,它的打字错误已经纠正。请检查代码。问题是未捕获类型错误:无法设置未定义的属性“\u DT_CellIndex”
-这与固定标题无关,与OPs original@CarstenLøvboAndersen也没有关系,证明这不是问题,问题完全在于嵌套tr
<tbody>
<tr class='ligth'>
<tr>