function my_datatable_load(oJsonParam){var key=oJsonParam.sKeyName;if(oJsonParam.columnDefs){oJsonParam.columnDefs[oJsonParam.columnDefs.length]={targets:0,sWidth:"10px",className:"dt-body-center",orderable:false,render:function(data,type,full,meta){return'<input type="checkbox" name=selected_names[] value="'+data[key]+'">'}}}else{oJsonParam.columnDefs=[{targets:0,sWidth:"10px",className:"dt-body-center",orderable:false,render:function(data,type,full,meta){return'<input type="checkbox" name=selected_names[] value="'+data[key]+'">'}}]}if(!oJsonParam.language){oJsonParam.language={emptyTable:" ",lengthMenu:"显示 _MENU_ 项",search:"查找",info:" ",sInfoEmpty:" ",paginate:{previous:"前一页",next:"下一页"}}}return $("#"+oJsonParam.sTableID).DataTable({bDestroy:true,bAutoWidth:false,sAjaxSource:oJsonParam.sListUrl,bSort:oJsonParam.bSort,order:[[1,"asc"]],language:oJsonParam.language,columns:oJsonParam.columns,columnDefs:oJsonParam.columnDefs,createdRow:function(nRow,oData,iDataIndex){if(oJsonParam.bSupportEdit){if(!oJsonParam.fEditFilter||oJsonParam.fEditFilter(oData)){$("td",nRow).eq(1).html("<a href="+oJsonParam.sEditUrl+"?name="+oData[key]+">"+$("td",nRow).eq(1).html()+"</a>")}}if(oJsonParam.fCreatedRow){oJsonParam.fCreatedRow(nRow,oData,iDataIndex)}return nRow}})}function my_datatable_init(oJsonParam){if(!oJsonParam){oJsonParam=new object}if(!oJsonParam.sTableID){oJsonParam.sTableID="MyDftTableID"}if(!oJsonParam.sEditUrl){oJsonParam.sEditUrl="edit.htm"}if(!oJsonParam.sSelectAllID){oJsonParam.sSelectAllID="MyDftSelectAllID"}if(!oJsonParam.columns){oJsonParam.columns=[{data:null,width:"10px"},{data:"Name"}]}if(oJsonParam.bSupportEdit==undefined){oJsonParam.bSupportEdit=true}if(!oJsonParam.sKeyName){oJsonParam.sKeyName="Name"}if(oJsonParam.bSort==undefined){oJsonParam.bSort=true}return oJsonParam}function MyDataTable_Init(oJsonParam){oJsonParam=my_datatable_init(oJsonParam);var oTable=my_datatable_load(oJsonParam);$("#"+oJsonParam.sSelectAllID).on("click",function(){var rows=oTable.rows({search:"applied"}).nodes();$('input[type="checkbox"]',rows).prop("checked",this.checked)});$("#"+oJsonParam.sTableID+" tbody").on("change",'input[type="checkbox"]',function(){if(!this.checked){var el=$("#"+oJsonParam.sSelectAllID).get(0);if(el&&el.checked&&"indeterminate"in el){el.indeterminate=true}}})}function MyDataTable_DelSelected(oJsonParam){oJsonParam=my_datatable_init(oJsonParam);var oTable=$("#"+oJsonParam.sTableID).DataTable();var sNames="";oTable.$('input[type="checkbox"]').each(function(){if(this.checked){sNames+=this.value+","}});$.ajax({type:"POST",url:oJsonParam.sDeleteUrl+"&Delete="+sNames,async:false,dataType:"json",success:function(oJson){my_datatable_load(oJsonParam);if(oJson.infoarray){if(oJsonParam.infoNotify){oJsonParam.infoNotify(oJson.infoarray)}else{var sInfos="";for(x in oJson.infoarray){sInfos+=oJson.infoarray[x].info;sInfos+="\r\n"}window.alert(sInfos)}}}})}