datatable - rowcss / pageoption / title for long text. mysql auto free connection
This commit is contained in:
+31
-38
@@ -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 16th, 2023.
|
Last Modified : October 19th, 2023.
|
||||||
|
|
||||||
(c) 2009 - 2023, 3FONIA Software; WWW.3FONIA.COM.
|
(c) 2009 - 2023, 3FONIA Software; WWW.3FONIA.COM.
|
||||||
|
|
||||||
@@ -817,14 +817,16 @@ Request.JSONF = function(options){//oke
|
|||||||
|
|
||||||
var strBody = '<tbody>';
|
var strBody = '<tbody>';
|
||||||
$.each(ini.content, function(key, val){
|
$.each(ini.content, function(key, val){
|
||||||
strBody += '<tr'+(val[0].rowcss?' class="'+val[0].rowcss+'"':'')+'>';
|
strBody += '<tr>';
|
||||||
$.each(val, function(keyi, vali){
|
$.each(val, function(keyi, vali){
|
||||||
if (keyi == 0) return;
|
if (keyi == 0) return;
|
||||||
var _title = (ini.header[(keyi-1)].f.indexOf('awr') >= 0) ? ' title="' + vali.replace(/<br\s*[\/]?>/gi,'\n').replace(/(<([^>]+)>)/gi,'') + '"' : '';
|
strBody += '<td>' + vali + '</td>';
|
||||||
strBody += '<td'+_title+'>' + vali + '</td>';
|
|
||||||
});
|
});
|
||||||
if (ini.option.length > 0) {
|
if (ini.option.length > 0) {
|
||||||
var _tbtn1 = "", _tbtn2 = "";
|
var _tbtn1 = "", _tbtn2 = "";
|
||||||
|
if (val[0].rowcss) {
|
||||||
|
_tbtn1 += '<span class="rowcss '+val[0].rowcss+'"></span>';
|
||||||
|
}
|
||||||
if (val[0].button.length > 0) {
|
if (val[0].button.length > 0) {
|
||||||
$.each(val[0].button, function(keyb, valb){
|
$.each(val[0].button, function(keyb, valb){
|
||||||
var _icon = (valb[0]=='fon-tabel-dt') ? 'pencil' : valb[0];
|
var _icon = (valb[0]=='fon-tabel-dt') ? 'pencil' : valb[0];
|
||||||
@@ -842,7 +844,6 @@ Request.JSONF = function(options){//oke
|
|||||||
_tbtn1 += '<div><input class="form-check-input" type="checkbox" id="_cbox_'+val[0].checkbox.field+'" value="'+val[0].checkbox.value+'"></div>';
|
_tbtn1 += '<div><input class="form-check-input" type="checkbox" id="_cbox_'+val[0].checkbox.field+'" value="'+val[0].checkbox.value+'"></div>';
|
||||||
}
|
}
|
||||||
strBody += '<td class="">'+_tbtn1+_tbtn2+'</td>';
|
strBody += '<td class="">'+_tbtn1+_tbtn2+'</td>';
|
||||||
//strBody += '<td class="d-lg-flex justify-content-lg-center">'+_tbtn1+_tbtn2+'</td>';
|
|
||||||
}
|
}
|
||||||
strBody += '</tr>';
|
strBody += '</tr>';
|
||||||
});
|
});
|
||||||
@@ -866,19 +867,6 @@ Request.JSONF = function(options){//oke
|
|||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
cache: false,
|
cache: false,
|
||||||
data: post_data,
|
data: post_data,
|
||||||
/*success: function(){
|
|
||||||
var _lmenu = [];
|
|
||||||
$.each([10,25,50], function(key, val){
|
|
||||||
if (val > ini.content.length) return false;
|
|
||||||
_lmenu.push(val);
|
|
||||||
});
|
|
||||||
if (10 > ini.content.length){
|
|
||||||
opsi.lengthMenu.push([10],[10]);
|
|
||||||
}else{
|
|
||||||
_lmenu.push(-1), opsi.lengthMenu.push(_lmenu), _lmenu.pop();
|
|
||||||
_lmenu.push(ini.content.length), opsi.lengthMenu.push(_lmenu);
|
|
||||||
}
|
|
||||||
},*/
|
|
||||||
dataFilter: function(data){
|
dataFilter: function(data){
|
||||||
var json = jQuery.parseJSON(data), jsono = {};
|
var json = jQuery.parseJSON(data), jsono = {};
|
||||||
jsono.draw = json[0].draw;
|
jsono.draw = json[0].draw;
|
||||||
@@ -887,16 +875,12 @@ Request.JSONF = function(options){//oke
|
|||||||
jsono.data = json[0].data;
|
jsono.data = json[0].data;
|
||||||
|
|
||||||
$.each(jsono.data, function(key, val){
|
$.each(jsono.data, function(key, val){
|
||||||
//strBody += '<tr'+(val[0].rowcss?' class="'+val[0].rowcss+'"':'')+'>';
|
|
||||||
/*$.each(val, function(keyi, vali){
|
|
||||||
if (keyi == 0) return;
|
|
||||||
var _title = (ini.header[(keyi-1)].f.indexOf('awr') >= 0) ? ' title="' + vali.replace(/<br\s*[\/]?>/gi,'\n').replace(/(<([^>]+)>)/gi,'') + '"' : '';
|
|
||||||
});*/
|
|
||||||
// belum bisa css row/tr
|
|
||||||
// belum bisa title u/ awr class
|
|
||||||
var optval = val[0]; jsono.data[key].shift();
|
var optval = val[0]; jsono.data[key].shift();
|
||||||
if (ini.option.length > 0) {
|
if (ini.option.length > 0) {
|
||||||
var _tbtn1 = "", _tbtn2 = "";
|
var _tbtn1 = "", _tbtn2 = "";
|
||||||
|
if (optval.rowcss) {
|
||||||
|
_tbtn1 += '<span class="rowcss '+optval.rowcss+'"></span>';
|
||||||
|
}
|
||||||
if (optval.button.length > 0) {
|
if (optval.button.length > 0) {
|
||||||
$.each(optval.button, function(keyb, valb){
|
$.each(optval.button, function(keyb, valb){
|
||||||
var _icon = (valb[0]=='fon-tabel-dt') ? 'pencil' : valb[0];
|
var _icon = (valb[0]=='fon-tabel-dt') ? 'pencil' : valb[0];
|
||||||
@@ -924,17 +908,6 @@ Request.JSONF = function(options){//oke
|
|||||||
/******/
|
/******/
|
||||||
if (ini.option.length > 0) opsi.columnDefs.push({responsivePriority:3,targets:-1}, {orderable:false,targets:-1});
|
if (ini.option.length > 0) opsi.columnDefs.push({responsivePriority:3,targets:-1}, {orderable:false,targets:-1});
|
||||||
if (ini.navi.func_navi == '') opsi.paging = false;
|
if (ini.navi.func_navi == '') opsi.paging = false;
|
||||||
var _lmenu = [];
|
|
||||||
$.each([10,25,50], function(key, val){
|
|
||||||
if (val > ini.content.length) return false;
|
|
||||||
_lmenu.push(val);
|
|
||||||
});
|
|
||||||
if (10 > ini.content.length){
|
|
||||||
opsi.lengthMenu.push([10],[10]);
|
|
||||||
}else{
|
|
||||||
_lmenu.push(-1), opsi.lengthMenu.push(_lmenu), _lmenu.pop();
|
|
||||||
_lmenu.push(ini.content.length), opsi.lengthMenu.push(_lmenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ini.config.scrollbar == true) {
|
if (ini.config.scrollbar == true) {
|
||||||
opsi.scrollY = ini.config.scroll_height;
|
opsi.scrollY = ini.config.scroll_height;
|
||||||
@@ -958,8 +931,28 @@ Request.JSONF = function(options){//oke
|
|||||||
if (ini.navi.button) $('#'+ini.id+'Tabel_wrapper div.toolbar').html(_navibar);
|
if (ini.navi.button) $('#'+ini.id+'Tabel_wrapper div.toolbar').html(_navibar);
|
||||||
}
|
}
|
||||||
opsi.drawCallback = function(settings){
|
opsi.drawCallback = function(settings){
|
||||||
//var api = this.api();
|
$('#'+ini.id+'Tabel tbody td:last-child:has(span.rowcss)').each(function(){
|
||||||
//console.log( api.rows( {page:'current'} ).data() );
|
var span = $(this).find('span').attr('class').replace('rowcss ','');
|
||||||
|
$(this).parent().addClass(span);
|
||||||
|
});
|
||||||
|
$('#'+ini.id+'Tabel tbody td.awr').each(function(){
|
||||||
|
$(this).attr('title', $(this).html().replace(/<br\s*[\/]?>/gi,'\n').replace(/(<([^>]+)>)/gi,''));
|
||||||
|
});
|
||||||
|
var api = this.api(), menudiv = $('select[name="divDetailTabel_length"]');
|
||||||
|
var record = api.page.info().recordsTotal ?? 0, _lmenu = [];
|
||||||
|
$.each([10,25,50], function(key, val){
|
||||||
|
if (val > record && 10 < val) return false;
|
||||||
|
_lmenu.push(val);
|
||||||
|
});
|
||||||
|
if (10 < record && $.inArray(record, [25,50]) == -1){
|
||||||
|
_lmenu.push(record);
|
||||||
|
}
|
||||||
|
var _select = menudiv.val() ?? 10;
|
||||||
|
menudiv.empty();
|
||||||
|
$.each(_lmenu, function(key, val){
|
||||||
|
$('<option/>', {'value':val, 'text':val}).appendTo(menudiv);
|
||||||
|
});
|
||||||
|
menudiv.val(_select);
|
||||||
}
|
}
|
||||||
|
|
||||||
var otabel = $('#'+ini.id+'Tabel').DataTable(opsi);
|
var otabel = $('#'+ini.id+'Tabel').DataTable(opsi);
|
||||||
|
|||||||
+3
-3
@@ -6,9 +6,9 @@
|
|||||||
Desc. : v4 - Class database MySQL / MariaDB
|
Desc. : v4 - Class database MySQL / MariaDB
|
||||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||||
Created Date : February 2nd, 2007.
|
Created Date : February 2nd, 2007.
|
||||||
Last Modified : May 8th, 2021.
|
Last Modified : October 19th, 2023.
|
||||||
|
|
||||||
(c) 2008 - 2021, 3FONIA Software; WWW.3FONIA.COM.
|
(c) 2008 - 2023, 3FONIA Software; WWW.3FONIA.COM.
|
||||||
|
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ final class MySQL {
|
|||||||
private $rec = array();
|
private $rec = array();
|
||||||
private $row = 0;
|
private $row = 0;
|
||||||
private $halt_on_error = 1; //1: halt w message, 2: not halt w message, 3: not halt no message
|
private $halt_on_error = 1; //1: halt w message, 2: not halt w message, 3: not halt no message
|
||||||
private $auto_free = 0; //1: free query automatically, 0: must call free method to free query
|
private $auto_free = 1; //1: free query automatically, 0: must call free method to free query
|
||||||
private $db_config = null;
|
private $db_config = null;
|
||||||
private $err_num = 0;
|
private $err_num = 0;
|
||||||
private $err_msg = '';
|
private $err_msg = '';
|
||||||
|
|||||||
+2
-3
@@ -6,7 +6,7 @@
|
|||||||
Desc. : v4 - HTML Table (jQuery & Bootstrap)
|
Desc. : v4 - HTML Table (jQuery & Bootstrap)
|
||||||
Created By : Siau Pheng (siaupheng@3fonia.com).
|
Created By : Siau Pheng (siaupheng@3fonia.com).
|
||||||
Created Date : January 16th, 2008.
|
Created Date : January 16th, 2008.
|
||||||
Last Modified : October 17th, 2023.
|
Last Modified : October 19th, 2023.
|
||||||
|
|
||||||
(c) 2008 - 2023, 3FONIA Software; WWW.3FONIA.COM.
|
(c) 2008 - 2023, 3FONIA Software; WWW.3FONIA.COM.
|
||||||
|
|
||||||
@@ -252,13 +252,12 @@ final class Table {
|
|||||||
$t_order = ($i_order[0]['dir']=="asc") ? "ASC" : "DESC";
|
$t_order = ($i_order[0]['dir']=="asc") ? "ASC" : "DESC";
|
||||||
$i_order = $i_order[0]['column'];
|
$i_order = $i_order[0]['column'];
|
||||||
}
|
}
|
||||||
if (($i_length > $record) || (($i_start+1) >= $record)) $i_length = -1;
|
if (($i_length > $record) || ($i_start >= $record) || ($record <= 10)) $i_length = -1;
|
||||||
$sql_limit = ($i_start>=0 && $i_length != -1) ? " LIMIT ".$i_start.", ".$i_length : "";
|
$sql_limit = ($i_start>=0 && $i_length != -1) ? " LIMIT ".$i_start.", ".$i_length : "";
|
||||||
$sql_order = ($this->__afield[$i_order]) ? " ORDER BY ".$this->__afield[$i_order]." ".$t_order : "";
|
$sql_order = ($this->__afield[$i_order]) ? " ORDER BY ".$this->__afield[$i_order]." ".$t_order : "";
|
||||||
|
|
||||||
$adata['data'] = [];
|
$adata['data'] = [];
|
||||||
$this->__cdb->Query("SELECT ".$this->__tfield." FROM ".$this->__ttable.$this->__twhere.$sql_order.$sql_limit);
|
$this->__cdb->Query("SELECT ".$this->__tfield." FROM ".$this->__ttable.$this->__twhere.$sql_order.$sql_limit);
|
||||||
//$adata['sql'] = "SELECT ".$this->__tfield." FROM ".$this->__ttable.$this->__twhere.$sql_order.$sql_limit;
|
|
||||||
while ($this->__cdb->Next()) {
|
while ($this->__cdb->Next()) {
|
||||||
$abaris = [];
|
$abaris = [];
|
||||||
$aoption = ['button'=>[]];
|
$aoption = ['button'=>[]];
|
||||||
|
|||||||
Reference in New Issue
Block a user