@@ -160,9 +167,18 @@
let columns = [
- { id: "fullName", label: "Name" },
- { id: "age", label: "Age", width: "64px" },
- { id: "country", label: "Country", width: "200px", align: "center" }
+ {
+ id: "fullName",
+ label: "Name",
+ sortable: true, defaultSortOrder: "asc",
+ sortFunction: (a, b) => {
+ const fullNameA = `${a.firstName} ${a.lastName}`;
+ const fullNameB = `${b.firstName} ${b.lastName}`;
+ return fullNameA < fullNameB ? 1 : -1;
+ },
+ { id: "age", label: "Age", width: "64px", sortable: true, defaultSortOrder: "asc" },
+ { id: "tags", label: "Tags", width: "200px", align: "center", filter: true },
+ { id: "country", label: "Country", width: "200px", align: "center", sortable: true, defaultSortOrder: "asc" }
];
@@ -210,6 +226,9 @@
+
+
+
@@ -262,11 +281,14 @@
import columnsData from "./columns-data.js";
import eventsData from "./events-data.js";
import propsData from "./props-data.js";
+import slotsData from "./slots-data.js";
+
// Components
import Code from "../../Elements/Code/Code.vue";
import ComponentCode from "../../Elements/ComponentCode/ComponentCode.vue";
import AgeCustomCell from "./example/AgeCustomCell.vue";
import CountryCustomCell from "./example/CountryCustomCell.vue";
+import TagsCustomCell from "./example/TagsCustomCell.vue";
export default {
components: {
@@ -274,6 +296,7 @@ export default {
ComponentCode,
AgeCustomCell,
CountryCustomCell,
+ TagsCustomCell,
},
data() {
return {
@@ -298,17 +321,44 @@ export default {
{
id: "fullName",
label: "Name",
+ sortable: true,
+ defaultSortOrder: "asc",
+ sortFunction: (a, b) => {
+ const fullNameA = `${a.firstName} ${a.lastName}`;
+ const fullNameB = `${b.firstName} ${b.lastName}`;
+
+ return fullNameA < fullNameB ? 1 : -1;
+ },
},
{
id: "age",
label: "Age",
width: "64px",
+ sortable: true,
+ defaultSortOrder: "asc",
+ },
+ {
+ id: "priority",
+ label: "Priority",
+ width: "200px",
+ align: "center",
+ filter: true,
+ },
+ {
+ id: "tags",
+ label: "Tags",
+ width: "200px",
+ align: "center",
+ filter: true,
+ filterKey: "name",
},
{
id: "country",
label: "Country",
width: "200px",
align: "center",
+ sortable: true,
+ defaultSortOrder: "asc",
},
],
rows: [
@@ -316,36 +366,82 @@ export default {
firstName: "John",
lastName: "Doe",
age: 26,
+ priority: "High",
+ tags: [
+ {
+ name: "Tag 2",
+ color: "#ff69b4",
+ },
+ ],
country: "Germany",
},
{
firstName: "Jane",
lastName: "Doe",
age: 21,
+ priority: "Low",
+ tags: [
+ {
+ name: "Tag 2",
+ color: "#ff69b4",
+ },
+ ],
country: "Austria",
},
{
firstName: "Martine",
lastName: "Durand",
age: 35,
+ priority: "Medium",
+ tags: [
+ {
+ name: "My tag",
+ color: "#2AAA8A",
+ },
+ {
+ name: "Reviewed",
+ color: "#ff6954",
+ },
+ ],
country: "France",
},
{
firstName: "Giuseppe",
lastName: "Bompiani",
age: 64,
+ priority: "Low",
+ tags: [
+ {
+ name: "Tag 5",
+ color: "#bf70a4",
+ },
+ ],
country: "Italy",
},
{
firstName: "Enrico",
lastName: "Fermi",
age: 41,
+ priority: "low",
+ tags: [
+ {
+ name: "Missing",
+ color: "#fh69u6",
+ },
+ ],
country: "Italy",
},
{
firstName: "Lev Davidovitch",
lastName: "Landau",
age: 23,
+ priority: "Medium",
+ tags: [
+ {
+ name: "Tag 2",
+ color: "#ff69b4",
+ },
+ ],
country: "Russia",
},
],
@@ -354,6 +450,7 @@ export default {
propsData,
eventsData,
columnsData,
+ slotsData,
};
},
};
diff --git a/src/web/views/Components/Table/columns-data.js b/src/web/views/Components/Table/columns-data.js
index 684a1e90..0519b01c 100644
--- a/src/web/views/Components/Table/columns-data.js
+++ b/src/web/views/Components/Table/columns-data.js
@@ -24,4 +24,29 @@ export default [
"'left' ; 'center' ; 'right'",
"Set how text is aligned in the column.",
],
+ [
+ "sortable",
+ "Boolean",
+ "If you want to sort the column, set this to true. Sortable by id value.",
+ ],
+ [
+ "defaultSortOrder",
+ "'desc' ; 'asc'",
+ "Set the default sort order for the column.",
+ ],
+ [
+ "sortFunction",
+ "Function",
+ "Set a custom sort function for the column. If not specified, the default sort function will be used.",
+ ],
+ [
+ "filter",
+ "Boolean",
+ "If you want to filter the column, set this to true. Sortable by id value.",
+ ],
+ [
+ "filterKey",
+ "String",
+ "Set the key to specify a filter by.",
+ ]
];
diff --git a/src/web/views/Components/Table/example/TagsCustomCell.vue b/src/web/views/Components/Table/example/TagsCustomCell.vue
new file mode 100644
index 00000000..d4853c2c
--- /dev/null
+++ b/src/web/views/Components/Table/example/TagsCustomCell.vue
@@ -0,0 +1,36 @@
+
+
+
+ {{ tag.name }}
+
+
+
+
+
+
+
diff --git a/src/web/views/Components/Table/slots-data.js b/src/web/views/Components/Table/slots-data.js
new file mode 100644
index 00000000..9b9fe28e
--- /dev/null
+++ b/src/web/views/Components/Table/slots-data.js
@@ -0,0 +1,24 @@
+/* eslint-disable */
+export default [
+ [ "Slot name", "Description"],
+ [
+ "column-header-right",
+ "Use this slot to add some elements on the right of the column header.",
+ ],
+ [
+ "sub-header",
+ "Use this slot to add elements on the sub-header of the column header.",
+ ],
+ [
+ "cell-${column.id}",
+ "Use this slot with the column id to add custom content in the cell."
+ ],
+ [
+ "placeholder",
+ "Use this slot to add a custom placeholder when the table is empty."
+ ],
+ [
+ "column-filters",
+ "Use this slot to add custom filters for the table."
+ ]
+];