forked from mleibman/SlickGrid
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathexample-plugin-headermenu.html
155 lines (134 loc) · 4.07 KB
/
example-plugin-headermenu.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../slick.grid.css" type="text/css"/>
<link rel="stylesheet" href="../css/smoothness/jquery-ui-1.8.24.custom.css" type="text/css"/>
<link rel="stylesheet" href="../plugins/slick.headermenu.css" type="text/css"/>
<link rel="stylesheet" href="examples.css" type="text/css"/>
<style>
/**
* Style the drop-down menu here since the plugin stylesheet mostly contains structural CSS.
*/
.slick-header-menu {
border: 1px solid #718BB7;
background: #f0f0f0;
padding: 2px;
-moz-box-shadow: 2px 2px 2px silver;
-webkit-box-shadow: 2px 2px 2px silver;
min-width: 100px;
z-index: 20;
}
.slick-header-menuitem {
padding: 2px 4px;
border: 1px solid transparent;
border-radius: 3px;
}
.slick-header-menuitem:hover {
border-color: silver;
background: white;
}
.slick-header-menuitem-disabled {
border-color: transparent !important;
background: inherit !important;
}
.icon-help {
background-image: url(../images/help.png);
}
</style>
</head>
<body>
<div style="position:relative">
<div style="width:600px;">
<div id="myGrid" style="width:100%;height:500px;"></div>
</div>
<div class="options-panel">
<p>
This example demonstrates using the <b>Slick.Plugins.HeaderMenu</b> plugin to add drop-down menus to column
headers. (Hover over the headers.)
</p>
<h2>View Source:</h2>
<ul>
<li><A href="https://github.com/ddomingues/X-SlickGrid/blob/gh-pages/liveDemo/examples/example-plugin-headermenu.html"
target="_sourcewindow"> View the source for this example on Github</a></li>
</ul>
</div>
</div>
<script src="../lib/jquery-1.7.min.js"></script>
<script src="../lib/jquery.event.drag-2.2.js"></script>
<script src="../slick.core.js"></script>
<script src="../slick.grid.js"></script>
<script src="../plugins/slick.headermenu.js"></script>
<script>
var grid;
var columns = [
{id: "title", name: "Title", field: "title"},
{id: "duration", name: "Duration", field: "duration"},
{id: "%", name: "% Complete", field: "percentComplete"},
{id: "start", name: "Start", field: "start"},
{id: "finish", name: "Finish", field: "finish"},
{id: "effort-driven", name: "Effort Driven", field: "effortDriven"}
];
for (var i = 0; i < columns.length; i++) {
columns[i].header = {
menu: {
items: [
{
iconImage: "../images/sort-asc.gif",
title: "Sort Ascending",
command: "sort-asc"
},
{
iconImage: "../images/sort-desc.gif",
title: "Sort Descending",
command: "sort-desc"
},
{
title: "Hide Column",
command: "hide",
disabled: true,
tooltip: "Can't hide this column"
},
{
iconCssClass: "icon-help",
title: "Help",
command: "help"
}
]
}
};
}
var options = {
enableColumnReorder: false
};
$(function () {
var data = [];
for (var i = 0; i < 500; i++) {
data[i] = {
title: "Task " + i,
duration: "5 days",
percentComplete: Math.round(Math.random() * 100),
start: "01/01/2009",
finish: "01/05/2009",
effortDriven: (i % 5 == 0)
};
}
grid = new Slick.Grid("#myGrid", data, columns, options);
var headerMenuPlugin = new Slick.Plugins.HeaderMenu({});
headerMenuPlugin.onBeforeMenuShow.subscribe(function (e, args) {
var menu = args.menu;
// We can add or modify the menu here, or cancel it by returning false.
var i = menu.items.length;
menu.items.push({
title: "Menu item " + i,
command: "item" + i
});
});
headerMenuPlugin.onCommand.subscribe(function (e, args) {
alert("Command: " + args.command);
});
grid.registerPlugin(headerMenuPlugin);
})
</script>
</body>
</html>