Typescript Variables in custom renderer

Hi,

I was trying to use a typescript variable inside the custom render, I was always thrown out with an error as “Cannot read property ‘a’ of undefined”.

If it’s possible help me to fix it! else guide me how to use a typescript variable inside custom render.

Thanks in advance!

Hi @ebalasubramanian24

Can you share a demo? The follow information is insufficient for me to test the bug.

@aleksandra_budnik I had created a git repository for the example and the link is attached below.

When you run this code you will get an error as Cannot read property 'alignText' of undefined, here actually I’m trying to assign the text alignment dynamically, but getting error pls help me to fix this.

I am sorry but the build itself failed

Can I ask you to just copy paste your instance settings and the custom renderer function into the fiddle?

@aleksandra_budnik Plz check now… I had fixed that build issue…

The build succeeded.

I got a missing table and alignText issue in the console.

To fix that just change this from line 7 in the app.component.ts file to instance. You’ll get

td.style.textAlign = instance.alignText;

After resolving this issue I do not get any errors. How to get the issue that you’ve mentioned in the first post?

“Cannot read property ‘a’ of undefined”.

the variable “a” was replaced with the name “alignText” in my example code.

Now it’s not showing the error but if I try to print that value inside the cell it’s showing as undefined but the value what I assigned to the variable has to be displayed there.

Had updated my code for that… Plz check that.

What exactly the header should look like? What is the goal?

Actually based on the metric what I’m choosing, I need to display the corresponding metric in the header of my table, where the header title remains same with changing the units alone.

The instance.alignText defined this way should be a method of the instance and as there is no method like that in the official API you get the error.

Maybe you can switch it to a className?

You mean the alignText or to use the classname instead of the instance?

yes, I would use a className.

Thank you @aleksandra_budnik… you made my day… Thank you so much :sweat_smile:

You are welcome. I am happy that it works for you