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,
45 ..._dt_default_ajax({ options: this.options }),
48 default_search: this.$route.query.q,
55 return { dataTablesDefaults }
58 redraw: function (url) {
59 this.$refs.table.dt().ajax.url(url).draw()
63 if (this.actions.hasOwnProperty("-1")) {
68 title: this.$__("Actions"),
70 render: (data, type, row) => {
72 this.actions["-1"].forEach(a => {
75 '<a class="edit btn btn-default btn-xs" role="button"><i class="fa fa-pencil"></i>' +
79 } else if (a == "delete") {
81 '<a class="delete btn btn-default btn-xs" role="button"><i class="fa fa-trash"></i>' +
87 return content.join(" ")
94 ".dt_button_clear_filter, .columns_controls, .export_controls, .dt_button_configure_table"
97 if (this.add_filters) {
98 this.options.orderCellsTop = true
101 if (this.table_settings) {
103 this.table_settings.hasOwnProperty("default_display_length") &&
104 this.table_settings.default_display_length != null
106 this.options.pageLength =
107 this.table_settings.default_display_length
110 this.table_settings.hasOwnProperty("default_sort_order") &&
111 this.table_settings.default_sort_order != null
113 this.options.order = [
114 [this.table_settings.default_sort_order, "asc"],
120 let dt = this.$refs.table.dt()
121 let table_node = dt.table().node()
122 if (this.add_filters) {
123 _dt_add_filters(table_node, dt, this.filters_options)
126 dt.on("column-visibility.dt", function () {
127 _dt_on_visibility(this.add_filters, table_node, dt)
129 .columns(this.hidden_ids)
132 if (Object.keys(this.actions).length) {
134 dt.on("draw", () => {
135 const dataSet = dt.rows().data()
136 Object.entries(this.actions).forEach(([col_id, actions]) => {
140 .each(function (idx) {
141 const data = dataSet[idx]
142 actions.forEach(action => {
143 $("." + action, this).on("click", e => {
144 self.$emit(action, data, dt, e)
153 const dt = this.$refs.table.dt()
161 type: [String, Function],