Datatables表格数据初始化时回调函数中修改要显示的值
生活随笔
收集整理的這篇文章主要介紹了
Datatables表格数据初始化时回调函数中修改要显示的值
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
場景
Datables初始化表數(shù)據(jù)后,返回的status狀態(tài)值為1,2,3
現(xiàn)在要根據(jù)返回值的狀態(tài)顯示相應的中文。
實現(xiàn)
{ data: 'status',render: function (data, type, full, meta ) {if(data.trim()=="1"){return '未提交'}else if(data.trim()=="2"){return '已提交'}else if(data.trim()=="3"){return '已打印'}else{return '未知狀態(tài)'}}? },舉例:
function dataTableInit(){return $('#wmsReceiveOrder_table_id').DataTable({"language": {"processing": "處理中...","lengthMenu": "顯示 _MENU_ 項結(jié)果","zeroRecords": "沒有匹配結(jié)果","info": "顯示第 _START_ 至 _END_ 項結(jié)果,共 _TOTAL_ 項","infoEmpty": "顯示第 0 至 0 項結(jié)果,共 0 項","infoFiltered": "(由 _MAX_ 項結(jié)果過濾)","infoPostFix": "","search": "搜索:","searchPlaceholder": "搜索...","url": "","emptyTable": "表中數(shù)據(jù)為空","loadingRecords": "載入中...","infoThousands": ",","paginate": {"first": "首頁","previous": "上頁","next": "下頁","last": "末頁"},"aria": {paginate: {first: '首頁',previous: '上頁',next: '下頁',last: '末頁'},"sortAscending": ": 以升序排列此列","sortDescending": ": 以降序排列此列"},"decimal": "-","thousands": "."},"processing": true,"searching" : false,"serverSide": true,"stateSave": true,"pageLength": 5,"lengthMenu": [ 5,10, 25, 50, 75, 100 ],"dom": '<"top">rt<"bottom"flpi><"clear">',"columnDefs": [ {"searchable": false,"orderable": false,"targets": 0}],columns: [{ data: 'id' },{ data: 'purchaseCode' },{ data: 'deliveryTime',render: function (data, type, full, meta ) {return moment(data).format("YYYY-MM-DD HH:mm:ss");} },{ data: 'createrName' },{ data: 'deliveryCode' },{ data: 'gmtCreat',render: function (data, type, full, meta ) {return moment(data).format("YYYY-MM-DD HH:mm:ss");} },{ data: 'createrName' },{ data: 'status',render: function (data, type, full, meta ) {if(data.trim()=="1"){return '未提交'}else if(data.trim()=="2"){return '已提交'}else if(data.trim()=="3"){return '已打印'}else{return '未知狀態(tài)'}}? },],"ajax": function (data, callback, setting) {$.each(data.columns,function (index,value) {//匹配所有input$("#searchCondition").find('input[type="text"]').each(function () {if(value.data === $(this).attr('id')){value.search.value = $(this).val();}});//匹配所有selectdebugger$("#searchCondition select").each(function () {debuggerif(value.data === $(this).attr('id')){value.search.value = $(this).val();}});})$.ajax({type: 'POST',url: "/wmsReceiveOrder/doPageForReceiveOrderTable",cache: false,? //禁用緩存data: JSON.stringify(data),? //傳入組裝的參數(shù)contentType: "application/json",dataType: "json",success: function (result) {debuggercallback(result);}})}})}?
總結(jié)
以上是生活随笔為你收集整理的Datatables表格数据初始化时回调函数中修改要显示的值的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java在MVC开发模式中使用try-c
- 下一篇: SpringBoot的日志管理(输出级别