Skip to content
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

to show all column settings #461

Open
wants to merge 1 commit into
base: v0
Choose a base branch
from
Open
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
28 changes: 9 additions & 19 deletions scripts/griddle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,29 +377,17 @@ var Griddle = React.createClass({
this.setPageSize(nextProps.resultsPerPage);
}
//This will updaet the column Metadata
this.columnSettings.columnMetadata = nextProps.columnMetadata;
if(nextProps.results.length > 0)
{
var deepKeys = deep.keys(nextProps.results[0]);

var is_same = (this.columnSettings.allColumns.length == deepKeys.length) && this.columnSettings.allColumns.every(function(element, index) {
return element === deepKeys[index];
if (nextProps.columnMetadata !== this.columnSettings.columnMetadata) {
this.columnSettings.columnMetadata = nextProps.columnMetadata;
this.columnSettings.allColumns = nextProps.columnMetadata.map(function(meta, index){
return meta.columnName
});

if(!is_same) {
this.columnSettings.allColumns = deepKeys;
}
}
else if(this.columnSettings.allColumns.length > 0)
{
this.columnSettings.allColumns = [];
}

if(nextProps.columns !== this.columnSettings.filteredColumns){
this.columnSettings.filteredColumns = nextProps.columns;
}


if(nextProps.selectedRowIds) {
var visibleRows = this.getDataForRender(this.getCurrentResults(), this.columnSettings.getColumns(), true);

Expand Down Expand Up @@ -428,9 +416,12 @@ var Griddle = React.createClass({
componentWillMount: function() {
this.verifyExternal();
this.verifyCustom();
var allColumns = this.props.columnMetadata.map(function(meta, index){
return meta.columnName
});

this.columnSettings = new ColumnProperties(
this.props.results.length > 0 ? deep.keys(this.props.results[0]) : [],
allColumns,
this.props.columns,
this.props.childrenColumnName,
this.props.columnMetadata,
Expand Down Expand Up @@ -910,8 +901,7 @@ var Griddle = React.createClass({

var meta = this.columnSettings.getMetadataColumns();

// Grab the column keys from the first results
keys = deep.keys(omit(results[0], meta));
keys = this.columnSettings.allColumns;

// sort keys by order
keys = this.columnSettings.orderColumns(keys);
Expand Down