3 :columns="tableColumns"
4 :options="{ ...dataTablesDefaults, ...allOptions }"
13 import DataTable from "datatables.net-vue3"
14 import DataTablesLib from "datatables.net"
15 import "datatables.net-buttons"
16 import "datatables.net-buttons/js/buttons.html5"
17 import "datatables.net-buttons/js/buttons.print"
18 import "datatables.net-buttons/js/buttons.colVis"
19 DataTable.use(DataTablesLib)
24 let hidden_ids, included_ids
25 ;[hidden_ids, included_ids] = _dt_visibility(
29 let buttons = _dt_buttons({
31 table_settings: this.table_settings,
35 tableColumns: this.columns,
41 pagingType: "full_numbers",
44 url: typeof this.url === "function" ? this.url() : this.url,
46 options: this.options,
47 default_filters: this.default_filters,
51 search: { search: this.$route.query.q },
59 return { dataTablesDefaults }
62 redraw: function (url) {
63 this.$refs.table.dt().ajax.url(url).draw()
67 if (this.actions.hasOwnProperty("-1")) {
72 title: this.$__("Actions"),
74 render: (data, type, row) => {
76 this.actions["-1"].forEach(a => {
79 '<a class="edit btn btn-default btn-xs" role="button"><i class="fa fa-pencil"></i>' +
83 } else if (a == "delete") {
85 '<a class="delete btn btn-default btn-xs" role="button"><i class="fa fa-trash"></i>' +
91 return content.join(" ")
98 ".dt_button_clear_filter, .columns_controls, .export_controls, .dt_button_configure_table"
101 if (this.add_filters) {
102 this.options.orderCellsTop = true
105 if (this.table_settings) {
107 this.table_settings.hasOwnProperty("default_display_length") &&
108 this.table_settings.default_display_length != null
110 this.options.pageLength =
111 this.table_settings.default_display_length
114 this.table_settings.hasOwnProperty("default_sort_order") &&
115 this.table_settings.default_sort_order != null
117 this.options.order = [
118 [this.table_settings.default_sort_order, "asc"],
124 let dt = this.$refs.table.dt()
125 let table_node = dt.table().node()
126 if (this.add_filters) {
127 _dt_add_filters(table_node, dt, this.filters_options)
130 dt.on("column-visibility.dt", function () {
131 _dt_on_visibility(this.add_filters, table_node, dt)
133 .columns(this.hidden_ids)
136 if (Object.keys(this.actions).length) {
138 dt.on("draw", () => {
139 const dataSet = dt.rows().data()
140 Object.entries(this.actions).forEach(([col_id, actions]) => {
144 .each(function (idx) {
145 const data = dataSet[idx]
146 actions.forEach(action => {
147 $("." + action, this).on("click", e => {
148 self.$emit(action, data, dt, e)
157 const dt = this.$refs.table.dt()
165 type: [String, Function],