Treeview under certain path
basictreeview
Console
PMA.UI version: 2.43.3
Tree view example showing how to load content underneath a certain path.
treeview_path.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_path.js"></script>
19 <link href="./css/treeview_path.css" type="text/css" rel="stylesheet">
20
21 <title>Treeview under certain path</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_path.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_path.js
1// Initial declarations
2var serverUrl = "https://host.pathomation.com/pma.core.2/";
3var serverUsername = "PMA_UI_demo";
4var serverPassword = "PMA_UI_demo";
5var treeviewElementSelector = "#treeview";
6var caller = "DemoPortal";
7var path = "Reference/Annotations/";
8
9jQuery(function () {
10 console.log(`PMA.UI version: ${PMA.UI.getVersion()}`);
11
12 // Create a context
13 var context = new PMA.UI.Components.Context({ caller: caller });
14
15 // Add an autologin authentication provider
16 new PMA.UI.Authentication.AutoLogin(context, [{ serverUrl: serverUrl, username: serverUsername, password: serverPassword }]);
17
18 // Create a tree view that will display the contents of PMA.core servers
19 var tree = new PMA.UI.Components.Tree(context, {
20 servers: [
21 {
22 name: "PMA.core v2.x",
23 url: serverUrl,
24 // Path of a folder in the server to show
25 path: path,
26 }
27 ],
28 element: treeviewElementSelector,
29 });
30
31 // Listen for the slide selected event by the tree view
32 tree.listen(PMA.UI.Components.Events.SlideSelected, function (args) {
33 console.log("Slide selected");
34 console.log(args);
35 });
36
37 // Listen for the directory selected event by the tree view
38 tree.listen(PMA.UI.Components.Events.DirectorySelected, function (args) {
39 console.log("Directory selected");
40 console.log(args);
41 });
42
43 // Listen for the server selected event by the tree view
44 tree.listen(PMA.UI.Components.Events.ServerSelected, function (args) {
45 console.log("Server selected");
46 console.log(args);
47 });
48
49 // Listen for the multiple selected event by the tree view
50 tree.listen(PMA.UI.Components.Events.MultiSelectionChanged, function (args) {
51 console.log("Multiple selected");
52 console.log(args);
53 });
54
55 // Listen for the double click event by the tree view
56 tree.listen(PMA.UI.Components.Events.TreeNodeDoubleClicked, function (args) {
57 console.log("Double click on node");
58 console.log(args);
59 });
60
61 // Listen for the server expanded event by the tree view
62 tree.listen(PMA.UI.Components.Events.ServerExpanded, function (args) {
63 console.log("Server expanded");
64 console.log(args);
65 });
66
67 // Listen for the directory expanded event by the tree view
68 tree.listen(PMA.UI.Components.Events.DirectoryExpanded, function (args) {
69 console.log("Directory expanded");
70 console.log(args);
71 });
72
73 // Listen for the search finished event by the tree view
74 tree.listen(PMA.UI.Components.Events.SearchFinished, function (args) {
75 console.log("Search finished");
76 console.log(args);
77 });
78
79 // Listen for the search failed event by the tree view
80 tree.listen(PMA.UI.Components.Events.SearchFailed, function (args) {
81 console.log("Search failed");
82 console.log(args);
83 });
84});