I am writing a directive to integrate SlickGrid with my angular app. I want to be able to configure SlickGrid columns with an angular template (instead of a formatter functi
I haven't tried to use a template, but I use the formatter in angular.
In the columns definition I used a string for the formatter:
// Column definition:
{id: 'money', name: 'Money', field: 'money', sortable: true, formatter: 'money'}
In the directive (or service [It depends of your architecture of your slickgrid implementation]) you could use for example:
var val = columns.formatter; // Get the string from the columns definition. Here: 'money'
columns.formatter = that.formatter[val]; // Set the method
// Method in directive or service
this.formatter = {
//function(row, cell, value, columnDef, dataContext)
money: function(row, cell, value){
// Using accounting.js
return accounting.formatNumber(value, 2, '.', ',');
}
}
I think when you use the same way in a directive to implement a template it just runs fine.
Btw: You could implement slick.grid.editors the same way...
Statement to the Comment from 'Simple As Could Be': In my experience when you use a directive with a css class (Columns definition: cssClass) you have to use $compile everytime an event happen (onScroll, aso)... The performance is terrible with this solution...
My solution of implementing formatters and editors in angular is not great but there is no big performance bottleneck.