xxxxxxxxxx
1
<template>
2
<div class="m-3">
3
<MDBInput class="mb-4" v-model="search3" />
4
<MDBDatatable :dataset="dataset10" :search="search3" hover @render="addIcons"/>
5
</div>
6
</template>
xxxxxxxxxx
1
<style>
2
#app {
3
font-family: Roboto, Helvetica, Arial, sans-serif;
4
}
5
</style>
xxxxxxxxxx
1
<script>
2
import { ref } from "vue";
3
import { MDBDatatable, MDBInput } from "mdb-vue-ui-kit";
4
export default {
5
components: {
6
MDBDatatable, MDBInput
7
},
8
setup() {
9
const search3 = ref("");
10
11
const dataset10 = {
12
columns: [
13
{ label: "Name", field: "name" },
14
{ label: "Position", field: "position" },
15
{ label: "Office", field: "office" },
16
{ label: "Contact", field: "contact", sort: false }
17
],
18
rows: [
19
{
20
name: "Tiger Nixon",
21
position: "System Architect",
22
office: "Edinburgh",
23
phone: "+48000000000",
24
email: "tiger.nixon@gmail.com"
25
},
26
{
27
name: "Sonya Frost",
28
position: "Software Engineer",
29
office: "Edinburgh",
30
phone: "+53456123456",
31
email: "sfrost@gmail.com"
32
},
33
{
34
name: "Tatyana Fitzpatrick",
35
position: "Regional Director",
36
office: "London",
37
phone: "+42123432456",
38
email: "tfitz@gmail.com"
39
}
40
].map((row,id) => {
41
return {
42
...row,
43
contact: `
44
<div class="add-icon">data-row-${id}</div>`
45
};
46
})
47
};
48
49
const iconsTemplate=`<button class="message-btn btn ms-2 btn-primary btn-floating btn-sm"><i class="fa fa-envelope"></i> </button>`
50
51
const addIcons = () => {
52
document.querySelectorAll(".add-icon").forEach(item=>{
53
const currentHTML = item.innerHTML
54
if (currentHTML.includes(iconsTemplate)) return
55
item.innerHTML = `${iconsTemplate} ${currentHTML}`
56
})
57
}
58
59
return {
60
dataset10, search3, addIcons
61
};
62
}
63
};
64
</script>
Console errors: 0