Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

How to change value and read the value of a Multi Select


Question

Posted

I hope someone can help me with the following.

 

My plan is to be able to loop through some objects and display the values for each object. It must be possible to change the values of each object and eventually update all objects.
Everything behind it is under control, but I have had a challenge with the UI.
I have created a user-defined layout with, among other things, sliders and Select (dropdown). Some Select are Single and others are Multi.
I can easily set the values in both Single and Multi select, in connection with building the page, but I would like to be able to change the values when I select an object from another Select (single).

 

I can change values with following code but exception for Multi Select.
Unfortunately, it only works the first time. If I select something in the dropdown or change slider and run the code again, it doesn't change.

 

    self:updateView("s1","value","25");
    self:updateView("s2","value","30");
    self:updateView("m1","selectedItem","1");
    self:updateView("m2","selectedItem","7");                        -- dosn't work
 

 

I have attached a small QuickApp to show what I mean, but the following is a part of the layout in $jason from getView

 

        {
          "visible": true,
          "components": [
            {
              "visible": true,
              "components": [
                {
                  "value": "0",
                  "min": "10",
                  "style": { "color": null, "weight": "3" },
                  "classes": [],
                  "eventBinding": { "onChanged": null },
                  "step": "1",
                  "max": "50",
                  "visible": true,
                  "text": null,
                  "name": "s1",
                  "unit": null,
                  "type": "slider"
                }
              ],
              "name": "missing_name_1108",
              "style": { "weight": "1.2" },
              "type": "horizontal"
            },
            {
              "style": { "weight": "0.5" },
              "name": "missing_name_1905",
              "type": "space"
            }
          ],
          "name": "missing_name_1941",
          "style": { "weight": "1.2" },
          "type": "vertical"
        },
        {
          "visible": true,
          "components": [
            {
              "visible": true,
              "components": [
                {

                  "value": "0",

                  "min": "1",
                  "style": { "color": null, "weight": "3" },
                  "classes": [],
                  "eventBinding": { "onChanged": null },
                  "step": "1",
                  "max": "100",
                  "visible": true,
                  "text": null,
                  "name": "s2",
                  "unit": null,
                  "type": "slider"
                },
              ],
              "name": "missing_name_1109",
              "style": { "weight": "1.2" },
              "type": "horizontal"
            },
          ],
          "name": "missing_name_1942",
          "style": { "weight": "1.2" },
          "type": "vertical"
        },
        {
          "visible": true,
          "components": [
            {
              "visible": true,
              "components": [
                {
                  "visible": true,
                  "text": "Fruits",
                  "name": "l6",
                  "style": { "textAlign": "center", "weight": "1.2" },
                  "type": "label"
                },
                {
                  "style": { "weight": "3" },
                  "options": [
                    { "text": "apple", "value": "1", "type": "option" },
                    { "text": "banana", "value": "2", "type": "option" },
                    { "text": "orange", "value": "3", "type": "option" }
                  ],
                  "eventBinding": { "onToggled": null },
                  "selectionType": "single",
                  "visible": true,
                  "text": "Choose one fruit:",
                  "name": "m1",
                  "values": [ "2" ],
                  "type": "select"
                }
              ],
              "name": "missing_name_1110",
              "style": { "weight": "1.2" },
              "type": "horizontal"
            },
          ],
          "name": "missing_name_1943",
          "style": { "weight": "1.2" },
          "type": "vertical"
        },
        {
          "visible": true,
          "components": [
            {
              "visible": true,
              "components": [
                {
                  "style": { "weight": "3" },
                  "options": [
                    { "text": "Tesla", "value": "1", "type": "option" },
                    { "text": "BMW", "value": "2", "type": "option" },
                    { "text": "Ferrari", "value": "3", "type": "option" },
                    { "text": "MB", "value": "4", "type": "option" },
                    { "text": "Aston Martin", "value": "5", "type": "option" },
                    { "text": "Volvo", "value": "6", "type": "option" },
                    { "text": "Fiat", "value": "7", "type": "option" },
                    { "text": "Ford", "value": "8", "type": "option" },
                    { "text": "VW", "value": "9", "type": "option" }
                  ],
                  "eventBinding": { "onToggled": null },
                  "selectionType": "multi",
                  "visible": true,
                  "text": "Choose some cars:",
                  "name": "m2",
                  "values": [ "2", "8" ],
                  "type": "select"
                },
              ],
              "name": "missing_name_1111",
              "style": { "weight": "1.2" },
              "type": "horizontal"
            },
            {
              "style": { "weight": "0.5" },
              "name": "missing_name_1909",
              "type": "space"
            }
          ],
          "name": "missing_name_1945",
          "style": { "weight": "1.2" },
          "type": "vertical"
        },
 

Please login or register to see this attachment.

4 answers to this question

Recommended Posts

  • 0
Posted

I guess Multi Select is not officially supported so you can't use self:updateView with it....?

  • 0
  • Inquirer
  • Posted

    I think you are right.
    Trying to get hold of their support. Maybe there is an undocumented way

    • 0
    Posted

    Hi,

     

    Try this.

    self:updateView("m2","selectedItems",{"7"});

    you can add more selected items

     

    • Like 1
    • 0
    Posted

    Yes, this works for me:

     

    e.g. :

    self:updateView("m2","selectedItems",{"7","10","253"});

     

    with this i can clear all selected items:

     

    self:updateView("m2","selectedItems",{""});

     

    Thanks for the Tip!

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...