Skip to content

Commit

Permalink
feat(columnPicker): add columnDef option to exclude a column from picker
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed May 20, 2019
1 parent bfe6512 commit 2c38c59
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions controls/slick.columnpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
} else {
columnLabel = defaults.headerColumnValueExtractor(columns[i]);
}

$("<label />")
.html(columnLabel)
.prepend($input)
Expand Down Expand Up @@ -176,7 +176,16 @@
ordered[i] = current.shift();
}
}
columns = ordered;

// filter out excluded column header when necessary
// (works with IE9+, older browser requires a polyfill for the filter to work, visit MDN for more info)
if (Array.isArray(ordered) && typeof ordered.filter === 'function') {
columns = ordered.filter(function(columnDef) {
return !columnDef.excludeFromColumnPicker;
});
} else {
columns = ordered;
}
}

function updateColumn(e) {
Expand Down
4 changes: 2 additions & 2 deletions examples/example4-model.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ <h2>View Source:</h2>
var grid;
var data = [];
var columns = [
{id: "sel", name: "#", field: "num", behavior: "select", cssClass: "cell-selection", width: 40, cannotTriggerInsert: true, resizable: false, selectable: false },
{id: "sel", name: "#", field: "num", behavior: "select", cssClass: "cell-selection", width: 40, cannotTriggerInsert: true, resizable: false, selectable: false, excludeFromColumnPicker: true },
{id: "title", name: "Title", field: "title", width: 120, minWidth: 120, cssClass: "cell-title", editor: Slick.Editors.Text, validator: requiredFieldValidator, sortable: true},
{id: "duration", name: "Duration", field: "duration", editor: Slick.Editors.Text, sortable: true},
{id: "%", defaultSortAsc: false, name: "% Complete", field: "percentComplete", width: 80, resizable: false, formatter: Slick.Formatters.PercentCompleteBar, editor: Slick.Editors.PercentComplete, sortable: true},
Expand All @@ -128,7 +128,7 @@ <h2>View Source:</h2>
columnPicker: {
columnTitle: "Columns",
hideForceFitButton: false,
hideSyncResizeButton: false,
hideSyncResizeButton: false,
forceFitTitle: "Force fit columns",
syncResizeTitle: "Synchronous resize",
},
Expand Down

0 comments on commit 2c38c59

Please sign in to comment.