cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

State definition using JSON configuration comparator problems

AC_10450068
4-Participant

State definition using JSON configuration comparator problems

Hello,

The stateDefinition object that I gave the advanced grid is not doing what I want it to do.

 

State Definition:


"stateDefinition": {
"fieldName": "example",
"name": "example_alarm",
"type": "non-fixed",
"states": [
{
"comparator": "<",
"name": "min_value",
"styleName": LowStyle",
"value": "10"
},
{
"comparator": ">",
"name": "max_value",
"styleName": "HighStyle",
"value": "100"
}
]
}

 

I am using the exact same layout for the string type columns of my grid and it behaves the way I want it to, since I am using the "==" comparator.

However for my number type columns, I am not getting the range that I want. The outcome is as if the comparator was "==". 

Now I realised that the value I gave it was a string, so I changed it to:

 

"stateDefinition": {
"fieldName": "example",
"name": "example_alarm",
"type": "non-fixed",
"states": [
{
"comparator": "<",
"name": "min_value",
"styleName": LowStyle",
"value": 10
},
{
"comparator": ">",
"name": "max_value",
"styleName": "HighStyle",
"value": 100
}
]
}

 

And now it does not work at all. Even though my defined column type  and the data shape types all match (number).

1 ACCEPTED SOLUTION

Accepted Solutions
slangley
23-Emerald II
(To:AC_10450068)

Hi @AC_10450068

 

We tested this under 9.3.6 and it appears to be working as expected in that release.  We used the AdvancedGrid sample file and tested both converted and unconverted.

 

Did it work for you before making changes?  Did you test it immediately after the conversion before modifying the style definitions?

 

Regards.

 

--Sharon

View solution in original post

5 REPLIES 5
jensc
17-Peridot
(To:AC_10450068)

Hello,

 

This should work as Javascript will first convert the string to a number before the comparison.

However I am not entirely sure how the grid handles the same situation.

 

You say you are using the "==" comparator, but in the configs you have provided you are not using it.

 

I am not really experienced using these grid configurations, but from what I can tell if your data is a number the second config should work.

 

Do you get any errors in the developer console or script/application logs?

 

Regards,

Jens

 

AC_10450068
4-Participant
(To:jensc)

Hello Jens,

 

Sorry for being unclear. The problem I am having is that it behaves as if I have used the "==" comparator, even though my config contains a different once. 

slangley
23-Emerald II
(To:AC_10450068)

Hi @AC_10450068.

 

Which version of ThingWorx are you running?  It seems to work under the latest release of ThingWorx.

 

Did you check for the possibility of typos?

 

Regards.

 

--Sharon

AC_10450068
4-Participant
(To:slangley)

Hello slangley,

 

I am using ThingWorx 9.3.0-b20. I have looked over the possibility of typos but I managed to replicate the problem using the AdvancedGridExample:

 

AC_10450068_0-1674683806431.png

AC_10450068_1-1674683824663.png

Same question:

https://community.ptc.com/t5/ThingWorx-Developers/Why-does-the-GridAdvancedExample-State-Definition-not-work/m-p/851095#M60923

slangley
23-Emerald II
(To:AC_10450068)

Hi @AC_10450068

 

We tested this under 9.3.6 and it appears to be working as expected in that release.  We used the AdvancedGrid sample file and tested both converted and unconverted.

 

Did it work for you before making changes?  Did you test it immediately after the conversion before modifying the style definitions?

 

Regards.

 

--Sharon

Top Tags