Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/js/core/factories/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -1875,8 +1875,6 @@ angular.module('ui.grid')

if (typeof(row.entity['$$' + col.uid]) !== 'undefined') {
col.cellDisplayGetterCache = $parse(row.entity['$$' + col.uid].rendered + custom_filter);
} else if (this.options.flatEntityAccess && typeof(col.field) !== 'undefined') {
col.cellDisplayGetterCache = $parse(row.entity[col.field] + custom_filter);
} else {
col.cellDisplayGetterCache = $parse(row.getEntityQualifiedColField(col) + custom_filter);
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/core/factories/GridRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ angular.module('ui.grid')
* @returns {string} resulting name that can be evaluated against a row
*/
GridRow.prototype.getEntityQualifiedColField = function(col) {
return gridUtil.preEval('entity.' + col.field);
return this.grid.options.flatEntityAccess ? 'entity[\'' + col.field + '\']' : gridUtil.preEval('entity.' + col.field);
};


Expand Down
17 changes: 17 additions & 0 deletions test/unit/core/factories/Grid.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,23 @@ describe('Grid factory', function () {
expect(grid.getCellDisplayValue(row,grid.columns[1])).toEqual("WEDNESDAY");
});

it('should apply angularjs filters with flatEntityAccess', function(){
var colDefs = [
{displayName:'date', field:'dateProp', cellFilter: 'date:"yyyy-MM-dd"'},
{displayName:'weekday', field:'dateProp', cellFilter: 'date:"EEEE" | uppercase'}
];
var grid = new Grid({ id: 1, columnDefs: colDefs, flatEntityAccess: true });
var rows = [
new GridRow(entity,1,grid)
];
grid.buildColumns();
grid.modifyRows([entity]);

var row = grid.rows[0];
expect(grid.getCellDisplayValue(row,grid.columns[0])).toEqual("2015-07-01");
expect(grid.getCellDisplayValue(row,grid.columns[1])).toEqual("WEDNESDAY");
});

it('not overwrite column types specified in options', function() {

var grid1 = new Grid({ id: 3 });
Expand Down