Skip to content

Commit 72f85f4

Browse files
committed
fix: merge standardcolumns and lxConfig columns before create header; and add jquery event for bootstrap
1 parent e264e61 commit 72f85f4

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

example/w_bootstrap/main.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@ const table = new LyxeaDatatable('#myTable', {
77
data: dataTableData,
88
scrollCollapse: true,
99
scrollY: 200,
10+
columns: [
11+
{
12+
data: 'first_name',
13+
name: 'first_name',
14+
title: 'Prénom',
15+
className: 'salut',
16+
maSuperConfig: 'Ohé toto',
17+
},
18+
],
1019
lxConfig: {
1120
filters: true,
1221
headers: [
13-
{
14-
columns: [
15-
{
16-
data: 'first_name',
17-
name: 'first_name',
18-
title: 'Prénom',
19-
className: 'salut',
20-
maSuperConfig: 'Ohé toto',
21-
},
22-
],
23-
},
2422
{
2523
headerGroup: 'Mon super groupe',
2624
columns: [

lib/core/LyxeaDatatable.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ class LyxeaDatatable<T>
170170
}
171171

172172
if (lxConfig) {
173+
/*
174+
If columns in the standard object and in lxconfig, header generation is only based on lxconfig.
175+
This allows you to generate the header with all the columns (and not just the columns defined in lxconfig).
176+
*/
177+
if (lxConfig.headers && standardColumns) {
178+
lxConfig.headers?.unshift({ 'columns': [...standardColumns] });
179+
}
173180
new LxRenderer(lxConfig);
174181
const headersBuilder = this.#customColumnBuilder
175182
.setColsDef(lxConfig)
@@ -243,8 +250,6 @@ class LyxeaDatatable<T>
243250

244251
this.#dtButtons.parse(this.config.buttons);
245252

246-
//@ts-ignore
247-
window.lxConfig = this.config;
248253
/**
249254
* Initializing datatable
250255
* Init event, get the datable instance on event.detail
@@ -273,6 +278,13 @@ class LyxeaDatatable<T>
273278
__filterDataWithKey() {}
274279

275280
handleBootrapTabChange<T>(instance: DataTable<T>) {
281+
// For JQUERY user
282+
if (typeof $ == 'function') {
283+
$('a[data-toggle="tab"]').on('shown.bs.tab', function () {
284+
// @ts-ignore
285+
instance.draw();
286+
})
287+
}
276288
document.querySelectorAll('button[data-bs-toggle="tab"]').forEach((el) => {
277289
el.addEventListener('shown.bs.tab', () => {
278290
// @ts-ignore

0 commit comments

Comments
 (0)