Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion src/js/core/services/gridClassFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@
}

if ( filterType ){
col[templateType] = template.replace(uiGridConstants.CUSTOM_FILTERS, col[filterType] ? "|" + col[filterType] : "");
col[templateType] = template.replace(uiGridConstants.CUSTOM_FILTERS, function() {
return col[filterType] ? "|" + col[filterType] : "";
});
} else {
col[templateType] = template;
}
Expand Down
24 changes: 23 additions & 1 deletion test/unit/core/services/GridClassFactory.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,29 @@ describe('gridClassFactory', function() {
expect(testSetup.col.cellTemplate).toEqual('<div>a sample cell template with custom_filters</div>');
expect(testSetup.col.footerCellTemplate).toEqual('<div>a sample footer template with custom_filters</div>');
});


it('column builder passes double dollars as parameters to the filters correctly', function() {
testSetup.$templateCache.put('ui-grid/uiGridHeaderCell', '<div>a sample header template with CUSTOM_FILTERS</div>');
testSetup.$templateCache.put('ui-grid/uiGridCell', '<div>a sample cell template with CUSTOM_FILTERS</div>');
testSetup.$templateCache.put('ui-grid/uiGridFooterCell', '<div>a sample footer template with CUSTOM_FILTERS</div>');

testSetup.col.cellFilter = 'customCellFilter:row.entity.$$internalValue';
testSetup.col.headerCellFilter = 'customHeaderCellFilter:row.entity.$$internalValue';
testSetup.col.footerCellFilter = 'customFooterCellFilter:row.entity.$$internalValue';

gridClassFactory.defaultColumnBuilder( testSetup.colDef, testSetup.col, testSetup.gridOptions );

expect(testSetup.col.providedHeaderCellTemplate).toEqual('ui-grid/uiGridHeaderCell');
expect(testSetup.col.providedCellTemplate).toEqual('ui-grid/uiGridCell');
expect(testSetup.col.providedFooterCellTemplate).toEqual('ui-grid/uiGridFooterCell');

testSetup.$rootScope.$digest();

expect(testSetup.col.headerCellTemplate).toEqual('<div>a sample header template with |customHeaderCellFilter:row.entity.$$internalValue</div>');
expect(testSetup.col.cellTemplate).toEqual('<div>a sample cell template with |customCellFilter:row.entity.$$internalValue</div>');
expect(testSetup.col.footerCellTemplate).toEqual('<div>a sample footer template with |customFooterCellFilter:row.entity.$$internalValue</div>');
});

});

});