1 var Accessor =
function(table){
3 this.allowedTypes = [
"",
"data",
"download",
"clipboard"]
8 Accessor.prototype.initializeColumn =
function(column){
13 this.allowedTypes.forEach(
function(type){
14 var key =
"accessor" + (type.charAt(0).toUpperCase() + type.slice(1)),
17 if(column.definition[key]){
18 accessor =
self.lookupAccessor(column.definition[key]);
25 params: column.definition[key +
"Params"] || {},
32 column.modules.accessor = config;
36 Accessor.prototype.lookupAccessor =
function(value){
42 if(this.accessors[value]){
43 accessor = this.accessors[value]
45 console.warn(
"Accessor Error - No such accessor found, ignoring: ", value);
59 Accessor.prototype.transformRow =
function(dataIn, type){
61 key =
"accessor" + (type.charAt(0).toUpperCase() + type.slice(1));
64 var data = Tabulator.prototype.helpers.deepClone(dataIn || {});
66 self.table.columnManager.traverse(
function(column){
67 var value, accessor, params, component;
69 if(column.modules.accessor){
71 accessor = column.modules.accessor[key] || column.modules.accessor.accessor ||
false;
74 value = column.getFieldValue(data);
76 if(value !=
"undefined"){
77 component = column.getComponent();
78 params = typeof accessor.params ===
"function" ? accessor.params(value, data, type, component) : accessor.params;
79 column.setFieldValue(data, accessor.accessor(value, data, type, params, component));
89 Accessor.prototype.accessors = {};
93 Tabulator.prototype.registerModule(
"accessor", Accessor);