1 < classtable table-bordered table-striped table-hover ' style= ' Margin-bottom : 0; ' > 2 </ Table >
<script>varRowckarr=NewArray ();varCkall = 0; $ (document). Ready (function(){ varTable = setdatatable ($ (". Data-table"))); //Filter$ ('. Data-table '). Append ($ (' <tfoot><tr></tr></tfoot> '))); $('. data-table thead th '). each (function () { vartitle = $ ('. data-table thead th '). EQ ($ ( This). Index ()). text (); Th= $ (' <th></th> '); $('. Data-table tfoot tr '). append (th); Th.html (' <input type= ' text "placeholder=" ' +title+ ' "style=" width: ' +$ ( This). Width () + ' px; '/> ' ); } ); //Insert Select all checkbox$ (". Data-table"). Find (' thead tr th:first-child ')). prepend (' <input type= ' checkbox "value=" "id=" Chk_all "style=" padding:3px;margin-right:5px; "/>"); $("#chk_all"). Click (function(){ if(ckall==0){ $('. data-table tr TD. Rowckbox '). each (function(){ if($( This). attr ("Ckif") ==0){ $( This). attr ("Checked", ' true '); $( This). attr ("Ckif", 1); Rowckarr.push ($ ( This). attr (' datatd ')); } }); $(' #chk_all '). attr ("Checked", ' true '); Ckall= 1; }Else if(ckall==1){ $('. data-table tr TD. Rowckbox '). each (function(){ $( This). Removeattr ("Checked"); $( This). attr ("Ckif", 0); }); Rowckarr=NewArray (); Ckall= 0; $(' #chk_all '). Removeattr ("checked")); } $( This). Val (Ckall); Alert ("Rowckarr=" +Rowckarr); }); $("Tfoot input"). each (function(i) {$ ( This). On (' KeyUp change ',function() {table.columns (i). Search ( This. Value); } ); $( This). KeyDown (function(e) {if(e.keycode==13) {table.columns (i). Draw (); } } ); }); //Table Interlaced Color$ ('. Data-table tbody '). On (' click ', ' TR ',function () { if( $( This). Hasclass (' selected ') ) { $( This). Removeclass (' selected '); } Else{table.$ (' tr.selected '). Removeclass (' selected ')); $( This). AddClass (' selected '); } }); }); //Filter Tables This. setdatatable =function(selector) {returnSelector. DataTable ({alengthmenu: [5,10], Idisplaylength:5, Sdom:"< ' Row-fluid ' < ' span6 ' l>< ' span6 text-right ' f>r>t< ' row-fluid ' < ' span6 ' i>< ' span6 Text-right ' p>> ', Spaginationtype:"Bootstrap", Olanguage: {sprocessing:"In Process ...", Slengthmenu:"Show _menu_ Results", Szerorecords:"No matching results", Sinfo:"Showing _start_ to _end_ results, total _total_", Sinfoempty:"Showing No. 0 to No. 0 of 0 results", sinfofiltered:"(Filtered by _max_ results)", Ssearch:"Search:", Opaginate: {"Snext": "Next Page", "sprevious": "Prev"}}, Sajaxsource:"Admin_toshowentbonus", Bserverside:true, Bfilter:true //Filter Function, Bsort:false //title, Fnserverdata:function(ssource, Aodata, Fncallback) {$.ajax ({' type ': ' Get ', "ContentType": "Application/json", "url": ssource,"DataType": "JSON", "Data": {' Aodata ': Json.stringify (Aodata)},//Pass in JSON format"Success":function(RESP) {fncallback (RESP); } }); }, Aocolumns: [{"Mdata": "id", ' title ': ' ID ', ' bvisible ':false} ,{ "Mdata": "id", ' title ': ' Select All ', "Mrender":function(Data,type,row) {$ ("#rowCkbox" +data). Change (function(){ if($( This). attr ("Ckif") ==1){ $( This). Removeattr ("Checked"); for(vari=0;i<rowckarr.length;i++){ if(Rowckarr[i]==$ ( This). attr (' datatd ') ) {temp=Rowckarr[i]; Rowckarr[i]= Rowckarr[0]; rowckarr[0] =temp; Rowckarr.shift (); } } $(' #chk_all '). Removeattr ("checked")); Ckall= 0; $( This). attr ("Ckif", 0); }Else{ $( This). attr ("Checked", ' true '); $( This). attr ("Ckif", 1); Rowckarr.push ($ ( This). attr (' datatd ')); varCkflag =true; $('. data-table tr TD. Rowckbox '). each (function(){ if($( This). attr ("Ckif") ==0) {Ckflag=false; } }); if(Ckflag) {$ (' #chk_all '). attr ("Checked", ' true '); Ckall=1; } } $("#chk_all"). Val (Ckall); Alert ("Rowckarr=" +Rowckarr); }); return' <input type= ' checkbox "ckif = 0 class=" Rowckbox "id=" Rowckbox ' +data+ ' "datatd= ' +data+ '/> '; }} ,{ "Mdata": "Orderentname", ' title ': ' Enterprise name '} ,{ "Mdata": "Ordercode", ' title ': ' Order number '} ,{ "Mdata": "Ordergeneratedate", ' title ': ' Order time '} ,{ "Mdata": "Perval", ' title ': ' Return value (¥) '} ] }); }; </script>
DataTable Add Select All function