Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions dist/core/DtButtons.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ import { ButtonConfig, ConfigButtons } from 'datatables.net-dt';

declare class DtButtons {
getDefaults(): (string | {
extend: string;
exportOptions: {
orthogonal: string;
};
text?: undefined;
action?: undefined;
} | {
text: string;
action: (_: any, dt: any) => void;
extend?: undefined;
exportOptions?: undefined;
})[];
parse(config: true | ConfigButtons | (string | ButtonConfig)[]): true | ConfigButtons | (string | ButtonConfig)[];
}
Expand Down
37 changes: 26 additions & 11 deletions dist/lx_dt.js
Original file line number Diff line number Diff line change
Expand Up @@ -53286,22 +53286,22 @@ var M1 = Cl.exports;
const ks = /* @__PURE__ */ hl(M1), qa = {
DATE_DAY: {
render: function(a, v) {
return v === "display" || v === "filter" ? ks(a).format("DD/MM/YYYY") : a;
return v === "display" || v === "filter" || v === "export" ? ks(a).format("DD/MM/YYYY") : a;
}
},
DATE_WITH_SECOND: {
render: function(a, v) {
return v === "display" || v === "filter" ? ks(a).format("DD/MM/YYYY HH:mm:ss") : a;
return v === "display" || v === "filter" || v === "export" ? ks(a).format("DD/MM/YYYY HH:mm:ss") : a;
}
},
LOCAL_NUMBER: {
render: function(a, v) {
return v === "display" || v === "filter" ? a.toLocaleString() : a;
return v === "display" || v === "filter" || v === "export" ? a.toLocaleString() : a;
}
},
BOOLEAN_OUI_NON: {
render: function(a, v) {
return v === "display" || v === "filter" ? a === !0 ? "Oui" : "Non" : a;
return v === "display" || v === "filter" || v === "export" ? a === !0 ? "Oui" : "Non" : a;
}
},
NUMBER_FIXED_2: {
Expand Down Expand Up @@ -53337,8 +53337,8 @@ const ks = /* @__PURE__ */ hl(M1), qa = {
render: (a) => typeof a == "string" ? a.toLowerCase() : a
},
CUT_LONG_TEXT: {
createdCell: function(a, v) {
typeof v == "string" && v.length > 30 && (a.title = v, a.innerText = v.substring(0, 28) + "…");
render: function(a, v) {
return v === "display" && typeof a == "string" && a.length > 30 ? a.substring(0, 28) + "…" : a;
}
},
CHECKBOX: {
Expand All @@ -53353,7 +53353,7 @@ const ks = /* @__PURE__ */ hl(M1), qa = {
const v = a[1];
return {
render: function(g, w) {
return w === "display" || w === "filter" ? ks(g).format(v) : g;
return w === "display" || w === "filter" || w === "export" ? ks(g).format(v) : g;
}
};
}
Expand Down Expand Up @@ -53773,13 +53773,28 @@ _i = new WeakMap(), mi = new WeakMap(), yi = new WeakMap(), to = new WeakMap(),
class Z1 {
getDefaults() {
return [
"copyHtml5",
"excelHtml5",
"csvHtml5",
{
extend: "copyHtml5",
exportOptions: {
orthogonal: "export"
}
},
{
extend: "excelHtml5",
exportOptions: {
orthogonal: "export"
}
},
{
extend: "csvHtml5",
exportOptions: {
orthogonal: "export"
}
},
{
text: "JSON",
action: function(v, g) {
var w = g.buttons.exportData({ orthogonal: "export_json" });
var w = g.rows({ orthogonal: "export" }).data().toArray();
Wn.fn.dataTable.fileSave(
new Blob([JSON.stringify(w)]),
"Exported_data.json"
Expand Down
23 changes: 19 additions & 4 deletions lib/core/DtButtons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,28 @@ import $ from 'jquery';
class DtButtons {
getDefaults() {
return [
'copyHtml5',
'excelHtml5',
'csvHtml5',
{
extend: 'copyHtml5',
exportOptions: {
orthogonal: 'export',
},
},
{
extend: 'excelHtml5',
exportOptions: {
orthogonal: 'export',
},
},
{
extend: 'csvHtml5',
exportOptions: {
orthogonal: 'export',
},
},
{
text: 'JSON',
action: function (_: any, dt: any) {
var data = dt.buttons.exportData({ orthogonal: 'export_json' });
var data = dt.rows({ orthogonal: 'export' }).data().toArray();
// @ts-ignore
$.fn.dataTable.fileSave(
new Blob([JSON.stringify(data)]),
Expand Down
23 changes: 12 additions & 11 deletions lib/dto/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ import dayjs from 'dayjs';
const CustomRenderers: Record<string, any> = {
DATE_DAY: {
render: function (data: any, type: any) {
if (type === 'display' || type === 'filter') {
if (type === 'display' || type === 'filter' || type === 'export') {
return dayjs(data).format('DD/MM/YYYY');
}
return data;
},
},
DATE_WITH_SECOND: {
render: function (data: any, type: any) {
if (type === 'display' || type === 'filter') {
if (type === 'display' || type === 'filter' || type === 'export') {
return dayjs(data).format('DD/MM/YYYY HH:mm:ss');
}
return data;
},
},
LOCAL_NUMBER: {
render: function (data: any, type: any) {
if (type === 'display' || type === 'filter') {
if (type === 'display' || type === 'filter' || type === 'export') {
return data.toLocaleString();
}
return data;
},
},
BOOLEAN_OUI_NON: {
render: function (data: any, type: any) {
if (type === 'display' || type === 'filter') {
if (type === 'display' || type === 'filter' || type === 'export') {
return data === true ? 'Oui' : 'Non';
}
return data;
Expand Down Expand Up @@ -75,13 +75,15 @@ const CustomRenderers: Record<string, any> = {
typeof data === 'string' ? data.toLowerCase() : data,
},
CUT_LONG_TEXT: {
createdCell: function (td: any, cellData: any) {
if (typeof cellData === 'string') {
if (cellData.length > 30) {
td.title = cellData;
td.innerText = cellData.substring(0, 28) + '…';
render: function (data: any, type: any) {
if (type === 'display') {
if (typeof data === 'string') {
if (data.length > 30) {
return data.substring(0, 28) + '…';
}
}
}
return data;
},
},
CHECKBOX: {
Expand All @@ -96,8 +98,7 @@ const CustomRenderers: Record<string, any> = {
const format = match[1];
return {
render: function (data: any, type: any) {
if (type === 'display' || type === 'filter') {
//return moment(data).format(format);
if (type === 'display' || type === 'filter' || type === 'export') {
return dayjs(data).format(format);
}
return data;
Expand Down