jQuery Datatables 动态列+跨列合并实现代码
网络编程 2021-07-04 15:02www.168986.cn编程入门
这篇文章主要介绍了jQuery Datatables 动态列+跨列合并实现代码,需要的朋友可以参考下
有时候需要用到
html
<input type="hidden" name="thead_key" id="thead_key" value="<?php if(isset($thead_key)):?><?php echo $thead_key;?><?php endif;?>"> <input type="hidden" name="thead_num" id="thead_num" value="<?php if(isset($thead_num)):?><?php echo $thead_num;?><?php endif;?>"> <table class="table text-nowrap table-striped table-bordered table-hover dataTables_list"> <thead> <tr> <th rowspan="2"><div align="center">备注明细</div></th> <?php if(isset($thead_arr)):?> <th colspan="<?php echo count($thead_arr);?>"><div align="center">校区</div></th> <?php endif;?> </tr> <?php if(isset($thead_arr)):?> <?php foreach($thead_arr as $val):?> <th><div align="center"><?php echo $val;?></div></th> <?php endforeach;?> <?php endif;?> </thead> </table>
js代码基于jquery
var oTable = null; var initTable = function() { var thead_key = $("#thead_key").val(); var thead_num = $("#thead_num").val(); thead_key = thead_key.split(','); var column_names = new Array(); for(var i=0;i<=thead_num;i++) { column_names.push({"className":"text-c","sDefaultContent": ''}) } oTable = $(".dataTables_list").dataTable({ "sPaginationType": "full_numbers", "bLengthChange":true, "bFilter": false,//搜索栏 "bProcessing": false, "bPaginate": true, "bServerSide": true, "bSort": false, //排序功能 //"iDisplayLength":parseInt("{:config('admin_page_size')}"), "bAutoWidth": false, "sAjaxSource": "{:url('edu_report/ajax_school_group_product_list')}", "aoColumns": column_names,//封装好的数组 //给行赋值 "fnRowCallback": function(nRow, aData, iDisplayIndex) { $('td:eq(0)', nRow).html(aData.memo); $.each(thead_key, function(i, args) { $('td:eq('+(i+1)+')', nRow).html(aData["memo_t_"+args]); }) }, }); }
效果图:
主要是参考思路与想法,具体的就介绍到这了,如果有帮助希望以后多多支持狼蚁SEO。
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程