Issue
I have a function that assigns column definition to my grid. There is one key called valueGetter which i need to assign the function to call to get the value for this column. The problem i am facing is that my API returns this value as a string.
When I set it via
valueGetter: column.valueGetter,
it looks like this valueGetter: "this.getSellerAgentandOffice" and it does not work. But if i manually set it to valueGetter: this.getSellerAgentandOffice it works. So the question is how can I set the column.valueGetter String value as a function name ?
Also just as some additional info when i tried to use
valueGetter: this[column.valueGetter],
i am getting following error
To make it more clear about the issue i included a StackBlitz Sample
Solution
Not sure why the question was down voted 3 times even so i provided code and working sample. But what would one expect from some of these guys.
In any case if someone should run into a similar issue below is the code that fix the issue as i guess the error was due to fact that it could be possibly undefined or nothing.
const valueGetter = column.valueGetter as string;
valueGetterFunction = this[valueGetter] || '';
Answered By - MisterniceGuy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.