Skip to content

Commit

Permalink
Add globalData prop to pass in user-specified global data through Gr…
Browse files Browse the repository at this point in the history
…iddle component to every customRowComponent instance. May possibly be used in other places in the future.
  • Loading branch information
dlong500 committed Jan 3, 2016
1 parent bf33680 commit fd6b1f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions scripts/customRowComponentContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ var CustomRowComponentContainer = React.createClass({
"data": [],
"metadataColumns": [],
"className": "",
"customComponent": {}
"customComponent": {},
"globalData": {}
}
},
render: function() {
Expand All @@ -25,7 +26,7 @@ var CustomRowComponentContainer = React.createClass({
}

var nodes = this.props.data.map(function(row, index){
return <that.props.customComponent data={row} metadataColumns={that.props.metadataColumns} key={index} />
return <that.props.customComponent data={row} metadataColumns={that.props.metadataColumns} key={index} globalData={that.props.globalData} />
});

var footer = this.props.showPager&&this.props.pagingContent;
Expand Down
11 changes: 6 additions & 5 deletions scripts/griddle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ var Griddle = React.createClass({
"customPagerComponent": {},
"customFilterComponent": null,
"customFilterer": null,
"globalData": null,
"enableToggleCustom":false,
"noDataMessage":"There is no data to display.",
"noDataClassName": "griddle-nodata",
Expand Down Expand Up @@ -686,8 +687,8 @@ var Griddle = React.createClass({
getCustomGridSection: function(){
return <this.props.customGridComponent data={this.props.results} className={this.props.customGridComponentClassName} {...this.props.gridMetadata} />
},
getCustomRowSection: function(data, cols, meta, pagingContent){
return <div><CustomRowComponentContainer data={data} columns={cols} metadataColumns={meta}
getCustomRowSection: function(data, cols, meta, pagingContent, globalData){
return <div><CustomRowComponentContainer data={data} columns={cols} metadataColumns={meta} globalData={globalData}
className={this.props.customRowComponentClassName} customComponent={this.props.customRowComponent}
style={this.props.useGriddleStyles ? this.getClearFixStyles() : null} />{this.props.showPager&&pagingContent}</div>
},
Expand Down Expand Up @@ -724,11 +725,11 @@ var Griddle = React.createClass({
hasMorePages={hasMorePages}
onRowClick={this.props.onRowClick}/></div>)
},
getContentSection: function(data, cols, meta, pagingContent, hasMorePages){
getContentSection: function(data, cols, meta, pagingContent, hasMorePages, globalData){
if(this.props.useCustomGridComponent && this.props.customGridComponent !== null){
return this.getCustomGridSection();
} else if(this.props.useCustomRowComponent){
return this.getCustomRowSection(data, cols, meta, pagingContent);
return this.getCustomRowSection(data, cols, meta, pagingContent, globalData);
} else {
return this.getStandardGridSection(data, cols, meta, pagingContent, hasMorePages);
}
Expand Down Expand Up @@ -788,7 +789,7 @@ var Griddle = React.createClass({
// Grab the paging content if it's to be displayed
var pagingContent = this.getPagingSection(currentPage, maxPage);

var resultContent = this.getContentSection(data, cols, meta, pagingContent, hasMorePages);
var resultContent = this.getContentSection(data, cols, meta, pagingContent, hasMorePages, this.props.globalData);

var columnSelector = this.getColumnSelectorSection(keys, cols);

Expand Down

0 comments on commit fd6b1f4

Please sign in to comment.