admin管理员组文章数量:1332403
I have table:
HTML
<table id="mydata">
<thead>
<tr>
<th>Data 1</th>
<th>Data 2</th>
<th>Data 3</th>
<th>Data 4</th>
</tr>
</thead>
<tbody>
<tr class="main">
<td class="data_1">A</td>
<td class="data_2">B</td>
<td class="data_3">C</td>
<td class="data_4">D</td>
</tr>
</tbody>
</table>
When i'm using dataTable to sort with jquery:
JavaScript
jQuery('#mydata').dataTable({
"sDom": " ",
"bPaginate": false,
"bInfo": false,
'bFilter':false,
"aoColumns": [
null,
null,
null,
null
]
});
It's worked.
But, when i add child rows for main:
HTML
<table id="mydata">
<thead>
<tr>
<th>Data 1</th>
<th>Data 2</th>
<th>Data 3</th>
<th>Data 4</th>
</tr>
</thead>
<tbody>
<tr class="main">
<td class="data_1">A</td>
<td class="data_2">B</td>
<td class="data_3">C</td>
<td class="data_4">D</td>
</tr>
<tr class="detail-header">
<td><strong>A1</strong></td>
<td><strong>B1</strong></td>
<td><strong>C1</strong></td>
<td><strong>D1</strong></td>
</tr>
<tr class="detail">
<td><strong>A2</strong></td>
<td><strong>B2</strong></td>
<td><strong>C2</strong></td>
<td><strong>D2</strong></td>
</tr>
<tr class="control">
<td colspan="2"><a href="#">Show details</a></td>
<td colspan="2"><a href="#">Hide details</a></td>
</tr>
</tbody>
</table>
In that html: detail-header, detail and control are childs of main and they show when click to Show details, it's should ignore when sort but i seem they also sort by dataTable so i received error:
Uncaught TypeError: Cannot read property 'className' of undefined
I have table:
HTML
<table id="mydata">
<thead>
<tr>
<th>Data 1</th>
<th>Data 2</th>
<th>Data 3</th>
<th>Data 4</th>
</tr>
</thead>
<tbody>
<tr class="main">
<td class="data_1">A</td>
<td class="data_2">B</td>
<td class="data_3">C</td>
<td class="data_4">D</td>
</tr>
</tbody>
</table>
When i'm using dataTable to sort with jquery:
JavaScript
jQuery('#mydata').dataTable({
"sDom": " ",
"bPaginate": false,
"bInfo": false,
'bFilter':false,
"aoColumns": [
null,
null,
null,
null
]
});
It's worked.
But, when i add child rows for main:
HTML
<table id="mydata">
<thead>
<tr>
<th>Data 1</th>
<th>Data 2</th>
<th>Data 3</th>
<th>Data 4</th>
</tr>
</thead>
<tbody>
<tr class="main">
<td class="data_1">A</td>
<td class="data_2">B</td>
<td class="data_3">C</td>
<td class="data_4">D</td>
</tr>
<tr class="detail-header">
<td><strong>A1</strong></td>
<td><strong>B1</strong></td>
<td><strong>C1</strong></td>
<td><strong>D1</strong></td>
</tr>
<tr class="detail">
<td><strong>A2</strong></td>
<td><strong>B2</strong></td>
<td><strong>C2</strong></td>
<td><strong>D2</strong></td>
</tr>
<tr class="control">
<td colspan="2"><a href="#">Show details</a></td>
<td colspan="2"><a href="#">Hide details</a></td>
</tr>
</tbody>
</table>
In that html: detail-header, detail and control are childs of main and they show when click to Show details, it's should ignore when sort but i seem they also sort by dataTable so i received error:
Uncaught TypeError: Cannot read property 'className' of undefined
Share
Improve this question
edited Aug 22, 2014 at 7:09
Eugene Obrezkov
2,9962 gold badges18 silver badges35 bronze badges
asked Aug 22, 2014 at 6:56
rockyrocky
3394 gold badges9 silver badges21 bronze badges
3
- detail-header, detail and control are not childs of main, they are sibblings of main. Did you expect tbody to be main? – wallop Commented Aug 22, 2014 at 7:00
- yeah, i'm confused. I want datatable just sort with main, and detail-header, detail and control will depend on results is sorted. – rocky Commented Aug 22, 2014 at 7:11
- oh now i get it. You need to check the data table plugin if it allows to sort any particular row!!! – wallop Commented Aug 22, 2014 at 7:14
1 Answer
Reset to default 5dataTables does not accept colspans in <tbody>
. Place the last row (the row with links) in a <tfoot>
instead :
<tfoot>
<tr class="control">
<td colspan="2"><a href="#">Show details</a></td>
<td colspan="2"><a href="#">Hide details</a></td>
</tr>
</tfoot>
demo -> http://jsfiddle/71zcn578/
本文标签: javascriptUncaught TypeError Cannot read property 39className39 of undefined dataTableStack Overflow
版权声明:本文标题:javascript - Uncaught TypeError: Cannot read property 'className' of undefined dataTable - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742234298a2437788.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论