Skip to content

Commit 99c0265

Browse files
committed
Merge branch 'master' of github.com:6pac/SlickGrid
2 parents c30867d + 18a0357 commit 99c0265

File tree

3 files changed

+60
-16
lines changed

3 files changed

+60
-16
lines changed

controls/slick.columnpicker.js

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
/***
2+
* A control to add a Column Picker (right+click on any column header to reveal the column picker)
3+
*
4+
* USAGE:
5+
*
6+
* Add the slick.columnpicker.(js|css) files and register it with the grid.
7+
*
8+
* Available options, by defining a columnPicker object:
9+
*
10+
* var options = {
11+
* enableCellNavigation: true,
12+
* columnPicker: {
13+
* columnTitle: "Columns", // default to empty string
14+
*
15+
* // the last 2 checkboxes titles
16+
* forceFitTitle: "Force fit columns", // default to "Force fit columns"
17+
* syncResizeTitle: "Synchronous resize", // default to "Synchronous resize"
18+
* }
19+
* };
20+
*
21+
* @class Slick.Controls.ColumnPicker
22+
* @constructor
23+
*/
24+
125
'use strict';
226

327
(function ($) {
@@ -7,7 +31,11 @@
731
var columnCheckboxes;
832

933
var defaults = {
10-
fadeSpeed: 250
34+
fadeSpeed: 250,
35+
36+
// the last 2 checkboxes titles
37+
forceFitTitle: "Force fit columns",
38+
syncResizeTitle: "Synchronous resize"
1139
};
1240

1341
function init() {
@@ -19,8 +47,9 @@
1947
var $close = $("<button type='button' class='close' data-dismiss='slick-columnpicker' aria-label='Close'><span class='close' aria-hidden='true'>&times;</span></button>").appendTo($menu);
2048

2149
// user could pass a title on top of the columns list
22-
if(options.columnPickerTitle) {
23-
var $title = $("<div class='title'/>").append(options.columnPickerTitle);
50+
if(options.columnPickerTitle || (options.columnPicker && options.columnPicker.columnTitle)) {
51+
var columnTitle = options.columnPickerTitle || options.columnPicker.columnTitle;
52+
var $title = $("<div class='title'/>").append(columnTitle);
2453
$title.appendTo($menu);
2554
}
2655

@@ -70,21 +99,23 @@
7099
.appendTo($li);
71100
}
72101

102+
var forceFitTitle = (options.columnPicker && options.columnPicker.forceFitTitle) || defaults.forceFitTitle;
73103
$("<hr/>").appendTo($list);
74104
$li = $("<li />").appendTo($list);
75105
$input = $("<input type='checkbox' />").data("option", "autoresize");
76106
$("<label />")
77-
.text("Force fit columns")
107+
.text(forceFitTitle)
78108
.prepend($input)
79109
.appendTo($li);
80110
if (grid.getOptions().forceFitColumns) {
81111
$input.attr("checked", "checked");
82112
}
83113

114+
var syncResizeTitle = (options.columnPicker && options.columnPicker.syncResizeTitle) || defaults.syncResizeTitle;
84115
$li = $("<li />").appendTo($list);
85116
$input = $("<input type='checkbox' />").data("option", "syncresize");
86117
$("<label />")
87-
.text("Synchronous resize")
118+
.text(syncResizeTitle)
88119
.prepend($input)
89120
.appendTo($li);
90121
if (grid.getOptions().syncColumnCellResize) {

controls/slick.gridmenu.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@
1313
* var options = {
1414
* enableCellNavigation: true,
1515
* gridMenu: {
16-
* customTitle: "Custom Menus",
17-
* columnTitle: "Columns",
18-
* iconImage: "../images/drag-handle.png", // this is the Grid Menu icon (hamburger icon)
19-
* iconCssClass: "fa fa-bars", // you can provide iconImage OR iconCssClass
20-
* leaveOpen: false, // do we want to leave the Grid Menu open after a command execution? (false by default)
21-
* menuWidth: 18, // width that will be use to resize the column header container (18 by default)
22-
* resizeOnShowHeaderRow: true, // true by default
16+
* customTitle: "Custom Menus", // default to empty string
17+
* columnTitle: "Columns", // default to empty string
18+
* iconImage: "../images/drag-handle.png", // this is the Grid Menu icon (hamburger icon)
19+
* iconCssClass: "fa fa-bars", // you can provide iconImage OR iconCssClass
20+
* leaveOpen: false, // do we want to leave the Grid Menu open after a command execution? (false by default)
21+
* menuWidth: 18, // width that will be use to resize the column header container (18 by default)
22+
* resizeOnShowHeaderRow: true, // true by default
23+
*
24+
* // the last 2 checkboxes titles
25+
* forceFitTitle: "Force fit columns", // default to "Force fit columns"
26+
* syncResizeTitle: "Synchronous resize", // default to "Synchronous resize"
27+
*
2328
* customItems: [
2429
* {
2530
* // custom menu item options
@@ -95,8 +100,10 @@
95100
var columnCheckboxes;
96101
var _defaults = {
97102
fadeSpeed: 250,
103+
forceFitTitle: "Force fit columns",
98104
menuWidth: 18,
99-
resizeOnShowHeaderRow: false
105+
resizeOnShowHeaderRow: false,
106+
syncResizeTitle: "Synchronous resize"
100107
};
101108

102109
function init(grid) {
@@ -241,21 +248,23 @@
241248
.appendTo($li);
242249
}
243250

251+
var forceFitTitle = (_options.gridMenu && _options.gridMenu.forceFitTitle) || _defaults.forceFitTitle;
244252
$("<hr/>").appendTo($list);
245253
$li = $("<li />").appendTo($list);
246254
$input = $("<input type='checkbox' />").data("option", "autoresize");
247255
$("<label />")
248-
.text("Force fit columns")
256+
.text(forceFitTitle)
249257
.prepend($input)
250258
.appendTo($li);
251259
if (_grid.getOptions().forceFitColumns) {
252260
$input.attr("checked", "checked");
253261
}
254262

263+
var syncResizeTitle = (_options.gridMenu && _options.gridMenu.syncResizeTitle) || _defaults.syncResizeTitle;
255264
$li = $("<li />").appendTo($list);
256265
$input = $("<input type='checkbox' />").data("option", "syncresize");
257266
$("<label />")
258-
.text("Synchronous resize")
267+
.text(syncResizeTitle)
259268
.prepend($input)
260269
.appendTo($li);
261270
if (_grid.getOptions().syncColumnCellResize) {

examples/example4-model.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ <h2>View Source:</h2>
125125
];
126126

127127
var options = {
128-
columnPickerTitle: "Columns",
128+
columnPicker: {
129+
columnTitle: "Columns",
130+
forceFitTitle: "Force fit columns",
131+
syncResizeTitle: "Synchronous resize",
132+
},
129133
editable: true,
130134
enableAddRow: true,
131135
enableCellNavigation: true,

0 commit comments

Comments
 (0)