Simple treeview
basictreeview
Console
PMA.UI version: 2.43.3
Tree view example, showing available events.
treeview.html
1<!doctype >
2<html lang="en">
3
4<head>
5 <meta charset="utf-8">
6 <meta http-equiv="X-UA-Compatible" content="IE=10">
7 <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
8
9 <!-- Include PMA.UI required libraries downloaded or from CDN -->
10 <script src="./pma.ui/jquery-3.1.0.js"></script>
11 <link href="./pma.ui/font-awesome.min.css" type="text/css" rel="stylesheet">
12
13 <!-- Include PMA.UI script & css -->
14 <script src="./pma.ui/pma.ui.js"></script>
15 <link href="./pma.ui/pma.ui.css" type="text/css" rel="stylesheet">
16
17 <!-- Include custom script & css -->
18 <script src="./js/treeview.js"></script>
19 <link href="./css/treeview.css" type="text/css" rel="stylesheet">
20
21 <title>Simple Treeview</title>
22</head>
23
24<body>
25 <!-- The element that will host the treeview -->
26 <div id="treeview"></div>
27</body>
28
29</html>
treeview.css
1html,
2body
3{
4 height: 100%;
5 padding: 0px;
6 margin: 0px;
7}
8
9#treeview
10{
11 height: calc(100vh - 6px);
12}
treeview.js
1// Initial declarations
2var serverUrl = "https://host.pathomation.com/pma.core.3/";
3var serverUsername = "PMA_UI_demo";
4var serverPassword = "PMA_UI_demo";
5var treeviewElementSelector = "#treeview";
6var caller = "DemoPortal";
7
8jQuery(function () {
9 console.log(`PMA.UI version: ${PMA.UI.getVersion()}`);
10
11 // Create a context
12 var context = new PMA.UI.Components.Context({ caller: caller });
13
14 // Add an autologin authentication provider
15 new PMA.UI.Authentication.AutoLogin(context, [{ serverUrl: serverUrl, username: serverUsername, password: serverPassword }]);
16
17 // Create a tree view that will display the contents of PMA.core servers
18 var tree = new PMA.UI.Components.Tree(context, {
19 servers: [
20 {
21 name: "PMA.core v3.x",
22 url: serverUrl,
23 }
24 ],
25 element: treeviewElementSelector,
26 });
27
28 // Listen for the slide selected event by the tree view
29 tree.listen(PMA.UI.Components.Events.SlideSelected, function (args) {
30 console.log("Slide selected");
31 console.log(args);
32 });
33
34 // Listen for the directory selected event by the tree view
35 tree.listen(PMA.UI.Components.Events.DirectorySelected, function (args) {
36 console.log("Directory selected");
37 console.log(args);
38 });
39
40 // Listen for the server selected event by the tree view
41 tree.listen(PMA.UI.Components.Events.ServerSelected, function (args) {
42 console.log("Server selected");
43 console.log(args);
44 });
45
46 // Listen for the multiple selected event by the tree view
47 tree.listen(PMA.UI.Components.Events.MultiSelectionChanged, function (args) {
48 console.log("Multiple selected");
49 console.log(args);
50 });
51
52 // Listen for the double click event by the tree view
53 tree.listen(PMA.UI.Components.Events.TreeNodeDoubleClicked, function (args) {
54 console.log("Double click on node");
55 console.log(args);
56 });
57
58 // Listen for the server expanded event by the tree view
59 tree.listen(PMA.UI.Components.Events.ServerExpanded, function (args) {
60 console.log("Server expanded");
61 console.log(args);
62 });
63
64 // Listen for the directory expanded event by the tree view
65 tree.listen(PMA.UI.Components.Events.DirectoryExpanded, function (args) {
66 console.log("Directory expanded");
67 console.log(args);
68 });
69
70 // Listen for the search finished event by the tree view
71 tree.listen(PMA.UI.Components.Events.SearchFinished, function (args) {
72 console.log("Search finished");
73 console.log(args);
74 });
75
76 // Listen for the search failed event by the tree view
77 tree.listen(PMA.UI.Components.Events.SearchFailed, function (args) {
78 console.log("Search failed");
79 console.log(args);
80 });
81});