datatable catch json data
This commit is contained in:
+14
-7
@@ -4,7 +4,7 @@
|
|||||||
Desc. : JS - Fonia Custom Class v3
|
Desc. : JS - Fonia Custom Class v3
|
||||||
Created By : Siau Pheng ([email protected]).
|
Created By : Siau Pheng ([email protected]).
|
||||||
Created Date : June 19th, 2009.
|
Created Date : June 19th, 2009.
|
||||||
Last Modified : October 19th, 2023.
|
Last Modified : October 30th, 2023.
|
||||||
|
|
||||||
(c) 2009 - 2023, 3FONIA Software; WWW.3FONIA.COM.
|
(c) 2009 - 2023, 3FONIA Software; WWW.3FONIA.COM.
|
||||||
|
|
||||||
@@ -791,7 +791,7 @@ Request.JSONF = function(options){//oke
|
|||||||
var strAksi = 'Aksi', ChkField = '';
|
var strAksi = 'Aksi', ChkField = '';
|
||||||
$.each(ini.option, function(key, val){
|
$.each(ini.option, function(key, val){
|
||||||
if (val.type == 'checkbox'){
|
if (val.type == 'checkbox'){
|
||||||
strAksi = '<input type="checkbox" id="'+ini.id+'_cbhead_'+val.field+'" value="'+val.avalue[1]+'">';
|
strAksi = '<input class="form-check-input" type="checkbox" id="'+ini.id+'_cbhead_'+val.field+'" value="'+val.avalue[1]+'">';
|
||||||
ChkField = val.field;
|
ChkField = val.field;
|
||||||
}
|
}
|
||||||
if (val.type == 'button') aTombol[val.icon] = val.label;
|
if (val.type == 'button') aTombol[val.icon] = val.label;
|
||||||
@@ -869,11 +869,18 @@ Request.JSONF = function(options){//oke
|
|||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: post_data,
|
data: post_data,
|
||||||
dataFilter: function(data){
|
dataFilter: function(data){
|
||||||
var json = jQuery.parseJSON(data), jsono = {};
|
var json = {}, jsono = {'draw':0,'recordsTotal':0,'recordsFiltered':0,'data':[]};
|
||||||
|
try {
|
||||||
|
json = jQuery.parseJSON(data);
|
||||||
|
if (!jQuery.isEmptyObject(json) && json[0].draw){
|
||||||
jsono.draw = json[0].draw;
|
jsono.draw = json[0].draw;
|
||||||
jsono.recordsTotal = json[0].recordsTotal;
|
jsono.recordsTotal = json[0].recordsTotal;
|
||||||
jsono.recordsFiltered = json[0].recordsFiltered;
|
jsono.recordsFiltered = json[0].recordsFiltered;
|
||||||
jsono.data = json[0].data;
|
jsono.data = json[0].data;
|
||||||
|
}
|
||||||
|
} catch (e){
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
$.each(jsono.data, function(key, val){
|
$.each(jsono.data, function(key, val){
|
||||||
var optval = val[0]; jsono.data[key].shift();
|
var optval = val[0]; jsono.data[key].shift();
|
||||||
@@ -945,13 +952,13 @@ Request.JSONF = function(options){//oke
|
|||||||
// generate pagelength option
|
// generate pagelength option
|
||||||
var api = this.api(), menudiv = $('select[name="'+ini.id+'Tabel_length"]');
|
var api = this.api(), menudiv = $('select[name="'+ini.id+'Tabel_length"]');
|
||||||
var record = api.page.info().recordsTotal ?? 0, _lmenu = [];
|
var record = api.page.info().recordsTotal ?? 0, _lmenu = [];
|
||||||
$.each([10,25,50], function(key, val){
|
$.each([10,25,50,100], function(key, val){
|
||||||
if (val > record && 10 < val) return false;
|
if (val > record && 10 < val) return false;
|
||||||
_lmenu.push(val);
|
_lmenu.push(val);
|
||||||
});
|
});
|
||||||
if (10 < record && $.inArray(record, [25,50]) == -1){
|
/*if (10 < record && $.inArray(record, [25,50,100]) == -1){
|
||||||
_lmenu.push(record);
|
_lmenu.push(record);
|
||||||
}
|
}*/
|
||||||
var _select = menudiv.val() ?? 10;
|
var _select = menudiv.val() ?? 10;
|
||||||
menudiv.empty();
|
menudiv.empty();
|
||||||
$.each(_lmenu, function(key, val){
|
$.each(_lmenu, function(key, val){
|
||||||
@@ -1120,7 +1127,7 @@ if (jQuery.fn.dataTable) {
|
|||||||
"sLast": "<i class=\"cui-media-step-forward\"></i>"
|
"sLast": "<i class=\"cui-media-step-forward\"></i>"
|
||||||
},
|
},
|
||||||
"sEmptyTable": "Tidak ada data yang tersedia pada tabel ini",
|
"sEmptyTable": "Tidak ada data yang tersedia pada tabel ini",
|
||||||
"sProcessing": "Sedang memproses...",
|
"sProcessing": "",
|
||||||
"sLengthMenu": "_MENU_",
|
"sLengthMenu": "_MENU_",
|
||||||
"sZeroRecords": "Tidak ditemukan data yang sesuai",
|
"sZeroRecords": "Tidak ditemukan data yang sesuai",
|
||||||
"sInfo": "Menampilkan _START_ sampai _END_ dari _TOTAL_ entri",
|
"sInfo": "Menampilkan _START_ sampai _END_ dari _TOTAL_ entri",
|
||||||
|
|||||||
Reference in New Issue
Block a user