Announcement

Collapse
No announcement yet.

Setting suffix for value range in code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Setting suffix for value range in code

    Can somebody please explain how to properly add suffix to the display value (i.e. %) if the range has control (slider) and different icons (Status/Graphics) for sub-ranges?

    I managed to make it work, but still confused and really it doesn't make much sense to me.

    Where do I set the suffix? For the control (slider) or the Status/Graphics?

    For the control (slider) I just set: Suffix = "%"

    For Status/Graphics sub-ranges I set AdditionalData, it works, but in the device range configuration the Suffix is $%0$

    Code:
    statusGraphic.TargetRange.Suffix = HsFeature.GetAdditionalDataToken(0);
    statusGraphic.HasAdditionalData = true;
    AdditionalStatusData = new List<string>() { "%" };

    As I said - it works, but I don't understand. What's the meaning of HasAdditionalData, especially for the control?
    For the control (slider) For Status/Graphics sub-ranges
    Click image for larger version  Name:	2022-03-02 (3).png Views:	0 Size:	11.6 KB ID:	1529924 Click image for larger version  Name:	2022-03-02 (4).png Views:	0 Size:	10.5 KB ID:	1529925
    Click image for larger version  Name:	2022-03-02 (2).png Views:	0 Size:	72.8 KB ID:	1529923

    #2
    AdditionalData is designed to be used as replacement tokens, so you should use it only if your suffix can change at runtime, for example a temperature device which could be either " °C" or " °F"

    HS.UpdatePropertyByRef(dvRef, EProperty.AdditionalStatusData, new List<string>() { thermostat.Settings.UseCelsius ? " °C" : " °F" });

    if your suffix is always "%", then do not use any AdditionalData and set the range suffix to "%" in your StatusControl and StatusGraphic

    Comment


      #3
      What's the meaning of AdditionalData for the Controls anyway? Doesn't it only apply to Status?

      Comment


        #4
        Originally posted by alexbk66 View Post
        What's the meaning of AdditionalData for the Controls anyway? Doesn't it only apply to Status?
        No it can apply to controls too. Imagine instead of a slider you use a dropdown list for a control that set a temperature, you may want your values in that dropdown list to appear as either " °C" or " °F"

        Comment

        Working...
        X