Skip to content

Commit

Permalink
Added "onHeaderMouseEnter" and "onHeaderMouseLeave" events for column…
Browse files Browse the repository at this point in the history
… headers.
  • Loading branch information
mleibman committed Jun 18, 2012
1 parent a146f55 commit a648d5a
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions slick.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ if (typeof Slick === "undefined") {
.bind("scroll.slickgrid", handleScroll);
$headerScroller
.bind("contextmenu.slickgrid", handleHeaderContextMenu)
.bind("click.slickgrid", handleHeaderClick);
.bind("click.slickgrid", handleHeaderClick)
.delegate(".slick-header-column", "mouseenter", handleHeaderMouseEnter)
.delegate(".slick-header-column", "mouseleave", handleHeaderMouseLeave);
$focusSink
.bind("keydown.slickgrid", handleKeyDown);
$canvas
Expand Down Expand Up @@ -460,7 +462,7 @@ if (typeof Slick === "undefined") {

$headers.find(".slick-header-column")
.each(function() {
var columnDef = columns[columnsById[$(this).data("fieldId")]];
var columnDef = $(this).data("column");
if (columnDef) {
trigger(self.onBeforeHeaderDestroy, {
"headerNode": this,
Expand All @@ -481,7 +483,7 @@ if (typeof Slick === "undefined") {
.html("<span class='slick-column-name'>" + m.name + "</span>")
.width(m.width - headerColumnWidthDiff)
.attr("title", m.toolTip || "")
.data("fieldId", m.id)
.data("column", m)
.addClass(m.headerCssClass || "")
.appendTo($headers);

Expand Down Expand Up @@ -531,7 +533,7 @@ if (typeof Slick === "undefined") {
return;
}

var column = columns[getColumnIndex($col.data("fieldId"))];
var column = $col.data("column");
if (column.sortable) {
if (!getEditorLock().commitCurrentEdit()) {
return;
Expand Down Expand Up @@ -1924,15 +1926,27 @@ if (typeof Slick === "undefined") {
}
}

function handleHeaderMouseEnter(e) {
trigger(self.onHeaderMouseEnter, {
"column": $(this).data("column")
}, e);
}

function handleHeaderMouseLeave(e) {
trigger(self.onHeaderMouseLeave, {
"column": $(this).data("column")
}, e);
}

function handleHeaderContextMenu(e) {
var $header = $(e.target).closest(".slick-header-column", ".slick-header-columns");
var column = $header && columns[self.getColumnIndex($header.data("fieldId"))];
var column = $header && $header.data("column");
trigger(self.onHeaderContextMenu, {column: column}, e);
}

function handleHeaderClick(e) {
var $header = $(e.target).closest(".slick-header-column", ".slick-header-columns");
var column = $header && columns[self.getColumnIndex($header.data("fieldId"))];
var column = $header && $header.data("column");
if (column) {
trigger(self.onHeaderClick, {column: column}, e);
}
Expand Down Expand Up @@ -2783,6 +2797,8 @@ if (typeof Slick === "undefined") {
// Events
"onScroll": new Slick.Event(),
"onSort": new Slick.Event(),
"onHeaderMouseEnter": new Slick.Event(),
"onHeaderMouseLeave": new Slick.Event(),
"onHeaderContextMenu": new Slick.Event(),
"onHeaderClick": new Slick.Event(),
"onHeaderRendered": new Slick.Event(),
Expand Down

0 comments on commit a648d5a

Please sign in to comment.