xxxxxxxxxx
1
<div class="input-group m-4">
2
<div class="chips-placeholder" data-mdb-label-text="search" id="advanced-search-input"></div>
3
</div>
4
<div id="datatable"></div>
1
1
xxxxxxxxxx
1
const data = {
2
columns: [
3
{
4
label: 'Name',
5
field: 'name'
6
},
7
'Position',
8
'Office',
9
'Age',
10
'Start date',
11
'Salary',
12
],
13
rows: [
14
["Tiger Nixon", "System Architect", "Edinburgh", "61", "2011/04/25", "$320,800"],
15
["Garrett Winters", "Accountant", "Tokyo", "63", "2011/07/25", "$170,750"],
16
["Ashton Cox", "Junior Technical Author", "San Francisco", "66", "2009/01/12", "$86,000"],
17
["Cedric Kelly", "Senior Javascript Developer", "Edinburgh", "22", "2012/03/29", "$433,060"],
18
["Airi Satou", "Accountant", "Tokyo", "33", "2008/11/28", "$162,700"],
19
["Brielle Williamson", "Integration Specialist", "New York", "61", "2012/12/02", "$372,000"],
20
["Herrod Chandler", "Sales Assistant", "San Francisco", "59", "2012/08/06", "$137,500"],
21
["Rhona Davidson", "Integration Specialist", "Tokyo", "55", "2010/10/14", "$327,900"],
22
["Colleen Hurst", "Javascript Developer", "San Francisco", "39", "2009/09/15", "$205,500"],
23
["Sonya Frost", "Software Engineer", "Edinburgh", "23", "2008/12/13", "$103,600"],
24
["Jena Gaines", "Office Manager", "London", "30", "2008/12/19", "$90,560"],
25
["Quinn Flynn", "Support Lead", "Edinburgh", "22", "2013/03/03", "$342,000"],
26
["Charde Marshall", "Regional Director", "San Francisco", "36", "2008/10/16", "$470,600"],
27
["Haley Kennedy", "Senior Marketing Designer", "London", "43", "2012/12/18", "$313,500"]
28
],
29
};
30
31
const instance = new mdb.Datatable(document.getElementById('datatable'), data)
32
33
const chips = document.querySelector('.chips-placeholder')
34
const chipsInstance = mdb.ChipsInput.getOrCreateInstance(chips)
35
36
37
chips.addEventListener('add.mdb.chips', (e) => {
38
let text = '';
39
40
chipsInstance.allChips.forEach((el, index) => {
41
text = !text ? el.innerText : text + ' ' + el.innerText
42
})
43
44
instance.search(text);
45
46
})
47
48
chips.addEventListener('delete.mdb.chips', (e) => {
49
let text = '';
50
chipsInstance.allChips.forEach((el, index) => {
51
text = !text ? el.innerText : text + ' ' + el.innerText
52
})
53
instance.search(text);
54
})
Console errors: 0