forked from JLynch7/SlickGrid
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a Slick.Plugin.HeaderMenu plugin to add drop-down menus to colu…
…mn headers along with an example to demonstrate usage.
- Loading branch information
Showing
3 changed files
with
480 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<!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.16.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> | ||
</div> | ||
</div> | ||
|
||
<script src="../lib/jquery-1.7.min.js"></script> | ||
<script src="../lib/jquery.event.drag-2.0.min.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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* Menu button */ | ||
.slick-header-menubutton { | ||
position: absolute; | ||
right: 0; | ||
top: 0; | ||
bottom: 0; | ||
width: 14px; | ||
background-repeat: no-repeat; | ||
background-position: left center; | ||
cursor: pointer; | ||
|
||
display: none; | ||
border-left: thin ridge silver; | ||
} | ||
|
||
.slick-header-column:hover > .slick-header-menubutton, | ||
.slick-header-column-active .slick-header-menubutton { | ||
display: inline-block; | ||
} | ||
|
||
/* Menu */ | ||
.slick-header-menu { | ||
position: absolute; | ||
display: inline-block; | ||
margin: 0; | ||
padding: 2px; | ||
cursor: default; | ||
} | ||
|
||
|
||
/* Menu items */ | ||
.slick-header-menuitem { | ||
list-style: none; | ||
margin: 0; | ||
padding: 0; | ||
cursor: pointer; | ||
} | ||
|
||
.slick-header-menuicon { | ||
display: inline-block; | ||
width: 16px; | ||
height: 16px; | ||
vertical-align: middle; | ||
margin-right: 4px; | ||
background-repeat: no-repeat; | ||
background-position: center center; | ||
} | ||
|
||
.slick-header-menucontent { | ||
display: inline-block; | ||
vertical-align: middle; | ||
} | ||
|
||
|
||
/* Disabled */ | ||
.slick-header-menuitem-disabled { | ||
color: silver; | ||
} |
Oops, something went wrong.