Skip to content

fix(ui-grid-menu-button.js): Click on the menu button item checkbox … #6738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/js/core/directives/ui-grid-menu-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ angular.module('ui.grid')
function isColumnVisible(colDef) {
return colDef.visible === true || colDef.visible === undefined;
}

function getColumnIcon(colDef) {
return isColumnVisible(colDef) ? 'ui-grid-icon-ok' : 'ui-grid-icon-cancel';
}

// add header for columns
showHideColumns.push({
Expand All @@ -267,15 +271,19 @@ angular.module('ui.grid')
if ( colDef.enableHiding !== false ){
// add hide menu item - shows an OK icon as we only show when column is already visible
var menuItem = {
icon: isColumnVisible(colDef) ? 'ui-grid-icon-ok' : 'ui-grid-icon-cancel',
icon: getColumnIcon(colDef),
action: function($event) {
$event.stopPropagation();

service.toggleColumnVisibility( this.context.gridCol );

if ($event.target && $event.target.firstChild) {
$event.target.firstChild.className = isColumnVisible(this.context.gridCol.colDef) ?
'ui-grid-icon-ok' : 'ui-grid-icon-cancel';
if (angular.element($event.target)[0].nodeName === 'I') {
$event.target.className = getColumnIcon(this.context.gridCol.colDef);
}
else {
$event.target.firstChild.className = getColumnIcon(this.context.gridCol.colDef);
}
}
},
shown: function() {
Expand Down