6 Replies Latest reply: Jul 17, 2015 3:52 AM by Bryan Sng RSS

    Qlik Mashup API selectValues

    Bryan Sng

      Hello guys,

       

      Recently I have this issue about deselection using selectValues when selection is invalid.

      Assuming my extension has 2 dimensions (Zip Code, Building Name)

       

      Let's assume some data too:

       

      Zip CodeBuilding Name
      11111AAA
      11111BBB
      11111CCC
      22222DDD
      22222EEE

       

      Suppose the user current selection is:

       

      Zip Code: 11111

      Building Name: AAA, BBB, CCC

       

      What I does is to programmatically select the rest of the data:

       

      app.field('Zip Code').selectValues([22222], true, true);

      app.field('Building Name').selectValues(['DDD', 'EEE'], true, true);


      Then programmatically deselect the rest of the data:


      app.field('Zip Code').selectValues([22222], true, true);

      app.field('Building Name').selectValues(['DDD', 'EEE'], true, true);


      The result would be Building Name selection unable to deselect because the deselection of Zip Code has render the current 'DDD' and 'EEE' to be gray out in the selection bar. Repeatedly calling

       

      app.field('Building Name').selectValues(['DDD', 'EEE'], true, true);


      has no effect unless I select back Zip Code 22222 to "enable" the Building Name "DDD", "EEE".


      Do you guys have any workaround or even better, the correct way to deselect even when the selection is gray out?


        • Re: Qlik Mashup API selectValues
          Erik Wetterberg

          Why don't you use app.field('Building Name').clear() ?? Or possibly use app.field('Building Name').selectExcluded() ??


          Erik

            • Re: Qlik Mashup API selectValues
              Bryan Sng

              Yup, that's exactly what I have done finally but it does require several code changes to use the clear method.

               

              Previously:

              1) Get the current selection from custom extension object

              2) Append current selection to qlik selection bar

               

              Currently:

              1) Get the current selection from qlik selection bar

              2) Get the current selection from custom extenstion object

              3) Clear current selection from qlik selection bar

              4) Combine #1 and #2 selections together

              5) Append #4 selections to qlik selection bar

                • Re: Qlik Mashup API selectValues
                  Erik Wetterberg

                  I'm afraid I don't understand what you are trying to do.

                   

                  Your first step is selecting the rest of the data (selectAlternative ??). Does that work as expected?

                   

                  Then you want to go back to the initial selection? Is that what does not work??

                   

                  Erik

                    • Re: Qlik Mashup API selectValues
                      Bryan Sng

                      Hmm basically I'm doing a map extension.

                      User is able to select plotted markers on the map.

                      When selecting a plotted markers, based on the marker attributes, I will make a selection via selectValues to qlik side.

                       

                      So for example user now click on a train station in USA, user will see Zip Code 111 and Product ID AAA at qlik selection bar.

                      If user now decided to deselect the marker, system should remove the Zip Code 111 and Product ID AAA at qlik selection bar which is perfectly ok now since there is no other selection.

                       

                      However if user make another selection 1st before deselecting, say for example another bus station in Canada, user will see Zip Code 111, 999 and Product ID AAA, FFF at qlik selection bar.

                      If user now decided to deselect the marker at USA, system should remove the Zip Code 111 and Product ID AAA at qlik selection bar so that only Zip Code 999 and Product ID FFF remains.


                      However this will not work as after executing the following, the value for Product ID AAA will be gray out:

                        app.field("Postal Code").selectValues("111", false, true);

                      Subsequently executing the following to deselect Product ID AAA will not cause any effect in the selection bar.

                        app.field("Product ID").selectValues("AAA", false, true);

                        • Re: Qlik Mashup API selectValues
                          Erik Wetterberg

                          I think you need an unique ID for each selectable marker to make this work. Say for example that the user select

                          1. zip 1111, building AAA
                          2. zip 1111, building BBB
                          3. then deselects the first marker, should you deselect zip 1111 or not??

                          Or another example, the user selects

                          1. zip 1111, building AAA
                          2. zip 2222, building BBB

                          If the data now contains also 1111, BBB and/or 2222, AAA they will also be selected.

                           

                          If you instead used a unique id (possibly concatenation of zip + building) you can use just that field for selection and the associative logic will fix the rest.

                           

                          I hope I have not misunderstood everything...

                           

                          Erik

                            • Re: Qlik Mashup API selectValues
                              Bryan Sng

                              Hmm for your 1st scenario,

                               

                              1. zip 1111, building AAA
                              2. zip 1111, building BBB
                              3. then deselects the first marker, should you deselect zip 1111 or not??

                               

                              No, zip 1111 and building BBB will be selected finally.

                               

                              For your 2nd scenario,

                               

                              1. zip 1111, building AAA
                              2. zip 2222, building BBB

                              If the data now contains also 1111, BBB and/or 2222, AAA they will also be selected.

                               

                              It's not possible because if the qlik selection bar already contains 1111, BBB and/or 2222, then at the map side, those markers would already be selected so subsequent selection of them will only cause deselection instead.

                               

                              Finally yes I implemented with your unique id strategy and got over the hurdle, thanks a lot Erik!