Reputation: 7317
I want to enable headerTooltip
for all columns and I don't want to have to repeat this for all the columns I have for the different tables.
Is there a way to set a global columnDef or override defaults?
I am also interested in a way to do this on a per table basis if there's no global way.
Upvotes: 1
Views: 244
Reputation: 431
The best approach for customizing any angular component is to look at the source code and then write a decorator where your application can modify the component without needing to hack the component source. In this case we can see that we need to change the GridColumn.prototype.updateColumnDef
function where it copies settings from the column def to the column itself. We install our own default value (if it's undefined) and then let the unmodified method do its thing. This way the new global default can still be overridden in individual grids.
angular.module(name).config(
$provide => {
$provide.decorator('GridColumn', $delegate => {
const {updateColumnDef} = $delegate.prototype;
$delegate.prototype.updateColumnDef = function(colDef, isNew) {
if(colDef.headerTooltip === undefined)
colDef.headerTooltip = true;
updateColumnDef.call(this, colDef, isNew);
};
return $delegate;
});
}
});
Upvotes: 3