7 Replies Latest reply on Oct 1, 2019 12:28 AM by Akshar Jamgaonkar

    get only the changed filters

    Akshar Jamgaonkar

      Hello All,

       

      I am trying to do some processing with the filters used has applied on a dashboard, is there a i way to get only the filters which user has modified. I am currently useing getFiltersAsync, but that for example is returning all the filters. i want to get only the filters with which a user has interacted.

       

      Any help on this would be great, Thanks.

        • 1. Re: get only the changed filters
          Akshar Jamgaonkar

          hi all,

           

          any help on this would be great, thanks.

          • 2. Re: get only the changed filters
            Geraldine Zanolli

            Hi Akshar,

             

            You can try to:

            1. Add an event: Viz.addEventListener

            2. For FILTER_CHANGE

            3. And call getFiltersAsync() only when the filter has changed state

             

            I hope it is helpful,

            Gigi

            • 3. Re: get only the changed filters
              Akshar Jamgaonkar

              Hi Geraldine Zanolli,

               

              Thanks for your reply. Actually, we have a slightly different scenario.

               

              We want to provide a option to the user on our website to save the filters currently applied. Once the user clicks the button, we want to get the current filters he has applied / modified and we don't need the other filters he has not changed.

               

              I checked the documentation but could not find an option to retrieve only filters which user has changed, Can you please help.

               

              Thanks.

              • 4. Re: get only the changed filters
                Geraldine Zanolli

                Hi Akashar - you can store (in an array for example) the filters change every time a user is updating a filter using an event: FILTER_CHANGE but save them only when the user clicks on the button.

                 

                I hope it is helpful,

                Gigi

                • 5. Re: get only the changed filters
                  Akshar Jamgaonkar

                  Hello Geraldine Zanolli,

                   

                  Thanks for your reply. Sorry, I did not fully understand you. Are you suggesting the below

                   

                  1) Listen to the FILTER_CHANGE event and anytime an user changes filter, add that filter to an array

                  2) When the user clicks on the button in our application, refer to the array we created in step 1 and save only those filters.

                   

                  I was thinking of a different workaround but can you please confirm if this is possible.

                   

                  All of our categorical filters have a value "ALL" as the first value in the dropdown, but when I am using getAppliedValues i do not see "ALL" returned, Is this the expected behaviour?

                   

                  I was thinking, if we could get the string "ALL", we could safely assume that user has not interacted with the filter and skip it. Can you please confirm if this is possible?

                   

                  Looking forward to your reply. Thanks.

                  • 6. Re: get only the changed filters
                    Geraldine Zanolli

                    Hi Akshar,

                     

                    Yes, it was my suggestion

                     

                    Your workaround can work if you are sure that all the filters are selected when the user is opening the dashboard. Also, something else to keep in mind: If you leave all the values selected, the getFiltersAsync() method is not returning filter-values.

                     

                    I hope it is helpful,

                    Gigi

                    • 7. Re: get only the changed filters
                      Akshar Jamgaonkar

                      Hi Geraldine Zanolli,

                       

                      Thanks for your reply.

                       

                      Actually I am noticing a different behaviour where getFiltersAsync is returning values for all the filters even if user has modified just once.

                       

                      Also, can you please confirm one of my above points related to the "ALL" text. We have a filter which has show values like "All", "Texas", "Colorodo", "Arkansas" but when I use the getAppliedValues, I am only getting "Texas", "Colorado", "Arkansas" but I am *not* getting All back. How can I get all the values, so, if Filter has "All" option selected, how can i get that so i can assume that user has not updated the filter and not save it.

                       

                      Thanks.