7 Replies Latest reply: Aug 7, 2013 12:14 PM by DougP RSS

    Have "All" as Drop Down Selection Criteria

    ScriptMan


      I have a dropdown selector on a dashboard that requeries the Results section by way of a filter.  The field is REGION. Values are North, South, East, West.  However, I want the default value to be "ALL REGIONS".  I want the user to have the ability to see the grand total of all regions.  I don't know how to handle that at the filter level.  Can this be done?  How?

        • 1. Re: Have "All" as Drop Down Selection Criteria
          WVanSluys


          So your drop down look like this

           

          ALL REGIONS

          NORTH
          SOUTH
          EAST
          WEST

           

          One Option is if the ALL REGIONS is selected you Ignore your Filter thereby all Regions are selected.

           

          You could use the SelectedIndex property of the Drop Down to determine which one is selected.

           

          so rough code...

           

          if(DropDown1.SelectedIndex == 1)

          {

          ignore filter = true

          }

          else
          {

          set filter value

          ignore filter = false

          }

           

          HTH

           

          w

          • 2. Re: Have "All" as Drop Down Selection Criteria
            ScriptMan

            This works...thank you !

            • 3. Re: Have "All" as Drop Down Selection Criteria
              ScriptMan

              this is what I'm trying, unfortunately I'm getting a error.  Can you take a look at the syntax and logic and tell me why this isn't working?

               

               

              var Selection;

              Selection=drop_YearSelect.Item(drop_YearSelect.SelectedIndex);

              If(Selection == 1)
              {
              ignore filter = true
              }
              else
              {
              ignore filter = false

              ActiveDocument.Sections["Results_Master_SAC_AllAccounts"].Limits["Onboarddate Year"].SelectedValues.RemoveAll()
              ActiveDocument.Sections["Results_Master_SAC_AllAccounts"].CustomValues.RemoveAll()
              ActiveDocument.Sections["Results_Master_SAC_AllAccounts"].CustomValues.Add(Selection)
              ActiveDocument

              • 4. Re: Have "All" as Drop Down Selection Criteria
                WVanSluys

                If the code posted above is actual code then you have an issue with the 2 ignore statements.

                 

                I indicated that it was rough code because I did not know your section & limit object names.

                 

                Use the Console Window to show you the error or line with an error.

                 

                Are you using the Script Editor Object Tree to help you create your script?

                 

                Navigate to the Object you are interested in working with via Script.  The editor provides you the Methods and Properties associated with that Object.If you have a question how that Property or Method behaves or is used click the HELP in the lower left corner of the Script Editor.  It will take you to information on that Object, Collection, Method or Property and often times show you examples.

                 

                 

                 

                fix the Ignore

                and fix the CustomValues...

                 

                if you are still having an issue after you try navigating the editor Object Tree to the appropriate Objects/Methods/Properties and reviewing the HELP then please post what you have and the related error.

                • 5. Re: Have "All" as Drop Down Selection Criteria
                  ScriptMan

                  Here is my Code.  It is being used on the "OnSelect5ed" event for the drop down list.  Unfortunately It's not working.   Any suggestions:

                   

                  // Pass Drop Down selection to filter

                  var selected_list_count = ActiveDocument.Sections["Home"].Shapes["drop_YearSelect"].SelectedList.Count;

                  if (ActiveDocument.Sections["Home"].Shapes["drop_YearSelect"].SelectedList.Item(1)== 'All')
                  {

                  ActiveDocument.Sections["Results_Master_AllAccounts"].Limits["Boarddate Year"].Ignore = true;

                  }
                  else
                  {

                  ActiveDocument.Sections["Results_Master_AllAccounts"].Limits["Boarddate Year"].Ignore = false;

                  ActiveDocument.Sections["Results_Master_AllAccounts"].Limits["Boarddate Year"].CustomValues.RemoveAll();
                  ActiveDocument.Sections["Results_Master_AllAccounts"].Limits["Boarddate Year"].SelectedValues.RemoveAll();

                  for(var i=1; i<= selected_list_count; i++)
                  {
                       var x = ActiveDocument.Sections["Home"].Shapes["drop_YearSelect"].SelectedList.Item(i);
                       ActiveDocument.Sections["Results_Master_AllAccounts"].Limits["Boarddate Year"].CustomValues.Add(x);
                       ActiveDocument.Sections["Results_Master_AllAccounts"].Limits["Boarddate Year"].SelectedValues.Add(x);
                  }
                  }


                  • 6. Re: Have "All" as Drop Down Selection Criteria
                    WVanSluys

                    First off are you using a List Box (user can select 1 or many items) or a Drop Down (user can select only 1 item)?

                     

                    Your Code indicates a List Box.

                     

                    Drop Downs have event OnSelection but do not have SelectedList collection.  Are you using the Object Tree within the Script Editor?

                     

                    Are you getting errors in the Console Window?

                     

                    Try Using the

                     

                    Console.Writeln()

                     

                    Place it within your code to show values at various points.

                     

                    Console.Writeln("Before if")

                    Console.Writeln("In If Section")

                    Console.Writeln("In Else Section")

                     

                    Or within the for loop

                     

                    Console.Writeln("i = " + i )

                    Console.Writeln("x = " + x)

                    • 7. Re: Have "All" as Drop Down Selection Criteria
                      DougP

                      IRFramework does a good job of abstracting some of this so you don't have to deal with the inconsistent accessor methods for IR dashboard objects.  For example, there is a GetValue() method for CheckBox, RadioButton, TextLabel, TextBox, DropDown, and ListBox objects that returns an array containing the value(s) in the control.  For a dropdown, you would call it like this:

                      var sValue = ActiveDocument.Sections["Home"].Shapes["drop_YearSelect"].GetValue()[0];

                      This works because the dropdown can have only one item selected.  It returns the value of element 0 of the array into the sValue variable.  Similarly, you could use the selected items in a ListBox like this:

                      var arrValue = ActiveDocument.Sections["Home"].Shapes["drop_YearSelect"].GetValue();
                      for (var i = 0; i < arrValue.length; i++) {
                           //    do something 
                      }