From 9173ad4f34fc5a3496b0a5198e8ce1810d1eaa72 Mon Sep 17 00:00:00 2001 From: benni Date: Thu, 7 Mar 2013 11:22:44 +0100 Subject: [PATCH] Added mechanism to use function for retrieving cell values --- src/classes/row.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/classes/row.js b/src/classes/row.js index 1a367939..2bd1755d 100644 --- a/src/classes/row.js +++ b/src/classes/row.js @@ -63,6 +63,15 @@ window.kg.Row = function (entity, config, selectionService) { self.afterSelectionChange = config.afterSelectionChangeCallback; self.propertyCache = {}; self.getProperty = function (path) { - return self.propertyCache[path] || (self.propertyCache[path] = window.kg.utils.evalProperty(self.entity, path)); + if(typeof path === "string"){ + return self.propertyCache[path] || (self.propertyCache[path] = window.kg.utils.evalProperty(self.entity, path)); + }if(typeof path === "object" && path.alias && path.accessor){ + var alias = path.alias, + accessor = path.accessor; + return self.propertyCache[alias] || (self.propertyCache[alias] = accessor(self.entity)); + } + else{ + console.log("Field definition invalid:", path); + } }; -}; \ No newline at end of file +};