Perspective table column format

I would like to show the values in ‘kg’ in perspective table column.

For Example : 123.44 kg
It is possible to use column number format as 0,0.## ; 'Kg’
It is not working. Please advise.

I am using Ignition version 8.1.15.
I am refereeing below link
Data Type Formatting Reference - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)

1 Like

What is your data source ? Do you pull data from a database, from tags, from processing… ?

I am pulling data from database using named query.

For work around i have used CONCAT(value,'Kg') in named query. however, i am not able to sort the column.

you can use css ::after{content}

(here i use css injection)

}.psc-suffixKg:not(.ia_table__head__header__cell) .content::after{   padding-left: 2px; content:" kg"}{

2 Likes

Yea, that’s tricky. Adding ‘kg’ to the value makes it a string, so the column will be sorted alphanumerically, not what you usually want with weights…

So, I have a ‘solution’ for you. Note the quotes around ‘solution’. It’s not pretty, but it kind of works.
If you want to be able to sort the column numerically, then the values need to be numbers. So you can’t add ‘kg’ to them directly. However… css can add text after an element, with ::after.
Then it’s just a game of finding the proper selector.

Here’s my suggestion: Make a style class, with a background image property. In this property, we’ll need to inject some css in this form: } .psc-your_style_class[data-column-id=your_column_name] > .content::after { content: "Kg"; } {
where your_style_class is the name of the style class, and your_column_name is the name of the column where your weights are.
Now, add this class to the table’s cell.style.classes property.

In images (on the default table’s population column):

image

@victordcq : How does your selector work ? I did try using the column’s style classes but couldn’t figure it out.

2 Likes

Adding the class to the column styles gets it applied to all elements in the column. so i just use :not() to substract the header

It didn’t apply anywhere when I tried it. I guess I mistyped something, heh…

1 Like

Do you see a reason why the background-color wouldn’t apply here ?

did you fill in the field?

Yes I did:
image

weeeird xd perspective version?

8.1.10

i a bit further on 8.1.14. But yours is also still quite new, this should be working xd

Altho no acctually didnt they “recently” change the style of the table, i remember seeing some posts about the padding of the cells. Altho i see you already have that padding so no idea

maybe in 2021, couldn’t find anything about that in the 2022 change logs… Oh well, I don’t usually style table columns anyway :smiley:

Thank you for help Victor and Pascal.

I am able to add style class and my both issues solved.

I can see “Eng. unit” after value in same column and can sort the column clicking on column header.

Thank you once again.

1 Like