5 lines
1.9 KiB
JavaScript
5 lines
1.9 KiB
JavaScript
(function(f,g){f.extend(g.ext.buttons,{colvis:function(a,b){return{extend:"collection",text:function(a){return a.i18n("buttons.colvis","Column visibility")},className:"buttons-colvis",buttons:[{extend:"columnsToggle",columns:b.columns}]}},columnsToggle:function(a,b){return a.columns(b.columns).indexes().map(function(a){return{extend:"columnToggle",columns:a}}).toArray()},columnToggle:function(a,b){return{extend:"columnVisibility",columns:b.columns}},columnsVisibility:function(a,b){return a.columns(b.columns).indexes().map(function(a){return{extend:"columnVisibility",
|
|
columns:a,visibility:b.visibility}}).toArray()},columnVisibility:{columns:null,text:function(a,b,c){return c._columnText(a,c.columns)},className:"buttons-columnVisibility",action:function(a,b,c,d){a=b.column(d.columns);a.visible(void 0!==d.visibility?d.visibility:!a.visible())},init:function(a,b,c){var d=this,e=a.column(c.columns);a.on("column-visibility.dt"+c.namespace,function(a,b,e,f){e===c.columns&&d.active(f)}).on("column-reorder.dt"+c.namespace,function(){var e=a.column(c.columns);b.text(c._columnText(a,
|
|
c.columns));d.active(e.visible())});this.active(e.visible())},destroy:function(a,b,c){a.off("column-visibility.dt"+c.namespace).off("column-reorder.dt"+c.namespace)},_columnText:function(a,b){var c=a.column(b).index();return a.settings()[0].aoColumns[c].sTitle.replace(/\n/g," ").replace(/<.*?>/g,"").replace(/^\s+|\s+$/g,"")}},colvisRestore:{className:"buttons-colvisRestore",text:function(a){return a.i18n("buttons.colvisRestore","Restore visibility")},init:function(a,b,c){c._visOriginal=a.columns().indexes().map(function(b){return a.column(b).visible()}).toArray()},
|
|
action:function(a,b,c,d){b.columns().every(function(a){this.visible(d._visOriginal[a])})}},colvisGroup:{className:"buttons-colvisGroup",action:function(a,b,c,d){b.columns(d.show).visible(!0);b.columns(d.hide).visible(!1)},show:[],hide:[]}})})(jQuery,jQuery.fn.dataTable);
|