How to edit in a script a table component props.columns

Not allowed !

a = b = 0;

Not allowed !

:o oke then you can hate the teacher not the methode xd

There are no teachers in 42 :X

oh no idea what 42 is xd i thought it was the age you studied it lol › wiki42 (school) - Wikipedia

I don’t know for what you use Ignition perspective solution but i use it for work, not to play or for fun.

1 Like

I use it for work.
And I did study code at university too. I learned much more at 42, which is NOT an online course.

If I asked those question, it’s because I believe there is a better solution to your problem. Now, if you’d rather believe I’m a kid that just plays around with ignition, fine.

1 Like

I do not want to be offensive to you or your skills; i’ve only post what 42 is it. If you have felt offended so I am sorry. In any case instead of continuing to make unseless controversies post your solution so I can improve my code, thanks.

Well then there’s some more information that could be useful:

My friend all the info of what i need to do are in the main title:

“How to edit in a script a table component props.columns”

Put in your test view a table component and try to populate your props.column that is initially empty, with a script that run pushing a button. Have you any good idea to improve my actual solution?

Then I guess a better question would be: What is your goal, ultimately ?
From what I gathered so far, you want to populate columns to translate the header field at runtime.
Is that correct, and is that all you need ? Does it have to be populated/translated when a button is clicked, or do you want it to be automatically translated to the current locale ?

Also, what is the source of your data, and what data structure does it use ?
I wouldn’t treat an array of objects the same as a dataset, for example.

1-My goal is “How to modify a component of the props.columns table in a script”.
2-The source is a dataset; I don’t know its number of columns before getting it, but I want to handle props.column [idx] of table component to always be equal to the number of columns of the dataset dinamically.
3-I want to translate the header of table.

Actually i’ve solve this problem but if you have any suggestions…

Modifying the columns props is not your goal here, translating the header is. It is merely a way to achieve that goal, but it might not be the only one. This is why I insist on this point, let me explain:
I’ve spent a lot of time on forums, sites, etc, like stack overflow. It is not unusual for the original question to be biased towards what the poster thinks might be the solution.
So instead of asking how to do what he wants, he asks how to do a certain step of what is, in his mind, the solution, without considering that it might not be the best one.

Now, about your specific case:
Is there any reason you don’t use the translation manager ?
I know I don’t like using it, the translation is a bit slower than calling translate explicitly, but it might be enough in your case.

Now, and maybe you tried this already, you could translate the headers in a script transform in your data binding. I can see this failing and not reevaluating when the locale change, which might be why you’re doing the columns shenanigans, as suggested in this post:

I’ve tried the system.util.translate() but not run at all at runtime, i’m investigating why.
At the moment I’ve solve using an expression binding like:
on props.columns[idx].header.title but this is a static solution implemented manually. I’d like to write the translation dinamically in the script.

To fix that, you could bind on the locale property.
If your dataset comes from a query and you don’t expect it to change after it’s been called, you could just bind data to your locale, and call the query in the transform script.
Otherwise, you’ll need to bind the columns (finally, we’re getting there !) to both locale and the data prop in an expression structure, then add a script transform like:

If you want the other fields there, go ahead and fill them up, but it works just fine without them.
This way you won’t have to manually add translate expressions or anything.


The XY Problem

1 Like

Yes, exactly. Couldn’t remember the name.

1 Like

Reading and understanding are two very different things and you are the proof!

Problem 1 - (not my primary goal but a corollary of it)
assumption: given a table component with a header that does NOT change, translate its text.
bind the expression to each props.column [-] of the table component using ‘translate ()’ on the props.field by explicitly specifying the session.props.locale parameter.

Problem 2 - (MY GOAL)
assumption: given a table component with header that changes at runtime, manage the props.column [-] (visibility, style, header translation, …) when the table header changes, considering that at the first access the table will be empty with props .column [-] with no elements.
An association does NOT solve the problem because the number of columns change at runtime. Instead of it a transform script that has the property of the table as its update trigger.
In this case the management of the columns will be dynamic BUT at the change of language the header values ​​will not change (the transform is linked to the of the table). The solution is to use a
customProps that is in binding with session.props.locale and with another script transform translate the headings of the n columns of the table (a for cyle that use the to know the actual number
of the column).

It doesn’t get any clearer than that !!!

I am sorry that you have wasted a lot of time to study and reading some ‘how to’ forum and that this has made you frustrated but I can not help you, onle an advise you to drink a nice chamomile mon cher ami!!!

This is exactly what the solution I suggested solves. It does bind against the locale prop, and populates columns dynamically at runtime.

I am not frustrated and I don’t consider this a waste of time.
I do consider your tones passive-aggressive, and you do seem to be stuck in your beliefs without wanting to “understand” what you’re “reading”, but rather “interpreting” it. So, with that, I’m gone. Have a good day.

1 Like