jQuery Datatables 動(dòng)態(tài)列+跨列合并實(shí)現(xiàn)代碼
更新時(shí)間:2020年01月30日 16:16:11 作者:賣萌的猴子
這篇文章主要介紹了jQuery Datatables 動(dòng)態(tài)列+跨列合并實(shí)現(xiàn)代碼,需要的朋友可以參考下
有時(shí)候需要用到
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">備注明細(xì)</div></th> <?php if(isset($thead_arr)):?> <th colspan="<?php echo count($thead_arr);?>"><div align="center">校區(qū)</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,//封裝好的數(shù)組
//給行賦值
"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_cnt_"+args]);
})
},
});
}
效果圖:

主要是參考思路與想法,具體的就介紹到這了,如果有幫助希望以后多多支持腳本之家。
您可能感興趣的文章:
- Jquery Datatables的使用詳解
- jQuery Datatables表頭不對(duì)齊的解決辦法
- jQuery插件DataTables分頁(yè)開發(fā)心得體會(huì)
- JQuery.dataTables表格插件添加跳轉(zhuǎn)到指定頁(yè)
- jQuery中Datatables增加跳轉(zhuǎn)到指定頁(yè)功能
- 利用JQuery實(shí)現(xiàn)datatables插件的增加和刪除行功能
- jQuery.datatables.js插件用法及api實(shí)例詳解
- jQuery DataTables插件自定義Ajax分頁(yè)實(shí)例解析
- jQuery插件datatables使用教程
- jQuery表格插件datatables用法匯總
- Jquery dataTables.treeGrid的樹形插件使用
相關(guān)文章
Jquery+Ajax+PHP+MySQL實(shí)現(xiàn)分類列表管理(上)
本文將采用Jquery+Ajax+PHP+MySQL來實(shí)現(xiàn)一個(gè)客戶分類列表的管理,如何利用Ajax和Json技術(shù)讓用戶操作起來覺得更輕松,感興趣的小伙伴們可以參考一下2015-10-10
jquery解析XML及獲取XML節(jié)點(diǎn)名稱的實(shí)現(xiàn)代碼
下面小編就為大家?guī)硪黄猨query解析XML及獲取XML節(jié)點(diǎn)名稱的實(shí)現(xiàn)代碼。小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-05-05
jquery實(shí)現(xiàn)簡(jiǎn)潔文件上傳表單樣式
這篇文章向大家推薦了一款基于jquery實(shí)現(xiàn)的簡(jiǎn)潔文件上傳表單樣式,實(shí)現(xiàn)效果大方精致,極力推薦給大家,希望大家可以喜歡。2015-11-11
簡(jiǎn)單實(shí)現(xiàn)限制uploadify上傳個(gè)數(shù)
本文給大家分享的是在使用uploadify上傳文件或者圖片的時(shí)候,如何做到限制上傳個(gè)數(shù)的方法,十分的簡(jiǎn)單方便實(shí)用,有需要的小伙伴可以參考下。2015-11-11

