Skip to content

Commit

Permalink
Merge pull request #634 from WellingGuzman/development
Browse files Browse the repository at this point in the history
hidden_input will hide table column
  • Loading branch information
wellingguzman committed Feb 7, 2015
2 parents a0ccee6 + 43a463e commit 22458c6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/core/table/table.bodyview.js
Expand Up @@ -91,7 +91,7 @@ function(app, Backbone, Sortable) {
});

var tableData = {
columns: this.collection.getColumns(),
columns: this.options.columns,
rows: rows,
sortable: this.options.sort,
selectable: this.options.selectable,
Expand Down
8 changes: 2 additions & 6 deletions app/core/table/table.headview.js
Expand Up @@ -193,13 +193,9 @@ function(app, Backbone) {

serialize: function() {
var order = this.collection.getOrder();
var blacklist = this.options.blacklist || [];
var columns = _.map(this.collection.getColumns(), function(column) {
return {name: column, orderBy: column === order.sort, desc: order.sort_order === 'DESC'};
});

columns = _.filter(columns, function(col) {
return !_.contains(blacklist, col.name);
var columns = _.map(this.options.columns, function(column) {
return {name: column, orderBy: column === order.sort, desc: order.sort_order === 'DESC'};
});

return {selectable: this.options.selectable, sortable: this.options.sort, columns: columns, deleteColumn: this.options.deleteColumn, hideColumnPreferences: this.options.hideColumnPreferences};
Expand Down
19 changes: 11 additions & 8 deletions app/core/table/table.view.js
Expand Up @@ -19,13 +19,8 @@ function(app, Backbone, TableHead, TableBody, TableFooter) {
TableBody: TableBody,

serialize: function() {
var blacklist = this.options.blacklist || [];
var columns = _.filter(this.collection.getColumns(), function(col) {
return !_.contains(blacklist, col);
});

return {
columns: columns,
columns: this.options.columns,
id: this.collection.table.id,
selectable: this.options.selectable,
sortable: this.options.sortable,
Expand Down Expand Up @@ -67,7 +62,7 @@ function(app, Backbone, TableHead, TableBody, TableFooter) {
}

if (this.collection.length > 0) {
options = _.pick(this.options, 'collection', 'selectable', 'filters', 'preferences', 'structure', 'sort', 'deleteColumn', 'rowIdentifiers', 'saveAfterDrop', 'blacklist', 'highlight');
options = _.pick(this.options, 'collection', 'selectable', 'filters', 'preferences', 'structure', 'sort', 'deleteColumn', 'rowIdentifiers', 'saveAfterDrop', 'blacklist', 'highlight', 'columns');
options.parentView = this;
this.insertView('table', new this.TableBody(options));
}
Expand Down Expand Up @@ -136,7 +131,9 @@ function(app, Backbone, TableHead, TableBody, TableFooter) {
},

initialize: function(options) {
var collection = this.collection;
var collection = this.collection,
structure = this.collection.structure,
blacklist = this.options.blacklist || [];

this.listenTo(collection, 'sync', function(model, resp, options) {
if (options.silent) return;
Expand All @@ -150,6 +147,12 @@ function(app, Backbone, TableHead, TableBody, TableFooter) {
this.options.preferences = this.options.preferences || this.collection.preferences;
this.options.structure = this.options.structure || this.collection.structure;
this.options.table = this.options.table || this.collection.table;
this.options.columns = _.filter(this.collection.getColumns(), function(col) {
var columnModel = structure.get(col),
hiddenInput = (columnModel && columnModel.get('hidden_input') !== true);

return !_.contains(blacklist, col) && hiddenInput;
});

if (this.options.tableHead !== false) {
this.tableHead = true;
Expand Down

0 comments on commit 22458c6

Please sign in to comment.