-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·47 lines (44 loc) · 1.63 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Sortable Datatable Example</title>
<link href="./dataTable.css" rel="stylesheet">
</head>
<body>
<div id="testTable"></div>
<script src="./DataTable.js"></script>
</body>
<script>
let columnDefs = [
{value: "ID", key: "id", width: "10"},
{value: "Name", key: "name", width: "45"},
{value: "E-mail", key: "email", width: "45", searchable: true}
];
let options ={
columnDragHandle: "", // selector of handler (must be inside of th tag)
columnOnDragClass: "columnOnDrag",
rowOnDragClass: "rowOnDrag",
dragColumnSortable: true,
dragRowSortable: true,
sortable: true,
sortableUpIcon: "./sort-up.svg",
sortableDownIcon: "./sort-down.svg",
onIndexChange: function (oldIndex, newIndex, type, rowElement) { // type: row or column
// console.log(oldIndex, newIndex, type, rowElement)
}
};
let rowDatas = [
{id:1,name:"baris",email:"[email protected]"},
{id:2,name:"alpkan",email:"[email protected]"},
{id:3,name:"kenan",email:"[email protected]"},
{id:4,name:"tanzer",email:"[email protected]"},
{id:5,name:"serkan",email:"[email protected]"}
];
let dataTable1 = new DataTable("#testTable", columnDefs, rowDatas, options).create();
dataTable1.search("an");
dataTable1.addRow({id:5,name:"serkan2",email:"[email protected]"});
</script>
</html>