javascript - 数据表打印复杂标题打印预览
问题描述
嗨,我正在使用数据表,它很棒,但我遇到了像这样的复杂标题中的问题
<thead>
<tr><td>some text</td></tr>
<tr><td>some text</td></tr>
</thead>
现在在显示页面时就像这样 当我点击打印预览时我得到这样的结果
第一个已经消失tr
了,thead
我打开了 datatable.js 文件,我发现了这个
var addRow = function ( d, tag ) {
var str = '<tr>';
for ( var i=0, ien=d.length ; i<ien ; i++ ) {
// null and undefined aren't useful in the print output
var dataOut = d[i] === null || d[i] === undefined ?
'' :
d[i];
var classAttr = columnClasses[i] ?
'class="'+columnClasses[i]+'"' :
'';
str += '<'+tag+' '+classAttr+'>'+dataOut+'</'+tag+'>';
}
return str + '</tr>';
};
// Construct a table for printing
var html = '<table class="'+dt.table().node().className+'">';
html += '<thead>';
// Adding logo to the page (repeats for every page while print)
if(config.repeatingHead.logo) {
var logoPosition = (['left','right','center'].indexOf(config.repeatingHead.logoPosition) > 0) ? config.repeatingHead.logoPosition : 'right';
html += '<tr><th colspan="'+data.header.length+'" style="padding: 0;margin: 0;text-align: '+logoPosition+';"><img style="'+config.repeatingHead.logoStyle+'" src="'+config.repeatingHead.logo+'"/></th></tr>';
}
// Adding title (repeats for every page while print)
if(config.repeatingHead.title) {
html += '<tr><th colspan="'+data.header.length+'">'+config.repeatingHead.title+'</th></tr>';
}
if ( config.header ) {
html += addRow( data.header, 'th' );
}
html += '</thead>';
html += '<tbody>';
for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
html += addRow( data.body[i], 'td' );
}
html += '</tbody>';
if ( config.footer && data.footer ) {
html += '<tfoot>'+ addRow( data.footer, 'th' ) +'</tfoot>';
}
html += '</table>';
它只是在tad中添加最后一个tr,但我无法将第一个tr与打印预览一起放置,非常感谢
这是一个 jsfiddle ex,当您预览表格时,它在 thead 的拖行显示,但在打印预览中,它仅在 thead 的 tr 上显示
解决方案
正如Datatables 网站的本主题中所讨论的,此功能尚不可用。
推荐阅读
- javascript - svg 中的中心 D3 geoPath 美国地图
- c++ - 需要有关在 C++ 中处理线程的建议
- tsql - SSIS:将 SSIS 作业中的所有电子邮件连接到一封电子邮件?
- javascript - VueJs 如何使下拉组件接受不同类型的道具
- javascript - ReactJS - TypeError:this.state.cakes.map 不是函数
- laravel - laravel中aws中的公共网址问题
- linux - 在 Linux 机器上禁用 VSCode 自动更新
- graphql - 如何将 Ix AsyncIterator 用于 nest.js GraphQL 订阅
- python-3.x - 我试图弄清楚为什么在使用海龟库时我的方格不会填充黑色
- python - Tkinter 'space' 绑定和条目清除