Use "dropdownlist" for filtering

coenecoene Member Posts: 6
I have made a tabular form based on a table containing the field "status". I have set the property "optionstring" of this field on table-level. But now I want to place a "dropdownlist" on my form that is not connected with a certain record. I want to do this so that the user can select a certain status and then the records will be filtered on the selected status.

I have already tried to add a textbox in the form. I have set the optionstring of the textbox like the optionstring of the field in this table, and I have set the "dropdown" property of this textbox to yes, but this seems to be the wrong solution.

Comments

  • SavatageSavatage Member Posts: 7,142
    We've done something similar to our "Item List" form.
    We have a drop down box with several Filter Options & when selected the form filters as required.

    It's a text box at the bottom of the page SourceExp "Form Method"
    "Form Method" is a Global Variable type Option with these possible options:
    All Items,All Regular Items,Active Regular Items,All Internet Items,Active Internet Items,All Discontinued Items
    I use a case satatement & an assortment of SetFilters & Set Ranges to accomplish the task.
    We were constantly entering different filter on this form se we decided to get a little help.
    OnAfterValidate()
    CASE "Form Method" OF
    "Form Method"::"All Items": BEGIN
      RESET;
      SETCURRENTKEY(Description,"Description 2");
    END;
    "Form Method"::"All Regular Items": BEGIN
      RESET;
      SETCURRENTKEY(Description,"Description 2");
      SETFILTER("No.",'<100000');
    END;
    "Form Method"::"Active Regular Items": BEGIN
      RESET;
      SETCURRENTKEY(Description,"Description 2");
      SETRANGE(Blocked,FALSE);
      SETFILTER("No.",'<100000');
    END;
    "Form Method"::"All Internet Items": BEGIN
      RESET;
      SETCURRENTKEY(Description,"Description 2");
      SETFILTER("No.",'>99999');
    END;
    "Form Method"::"Active Internet Items": BEGIN
      RESET;
      SETCURRENTKEY(Description,"Description 2");
      SETRANGE(Blocked,FALSE);
      SETFILTER("No.",'>99999');
    END;
    "Form Method"::"All Discontinued Items": BEGIN
      RESET;
      SETCURRENTKEY(Description,"Description 2");
      SETRANGE(Blocked,TRUE);
    END; END;
    CurrForm.UPDATE;
    

    And since it's a non-editable form - you have to add to the textbox the following code else you can't access it
    OnActivate()
    CurrForm.EDITABLE(TRUE);
    OnDeactivate()
    CurrForm.EDITABLE(FALSE);
    

    Sample Vid: http://www.youtube.com/watch?v=lyD9a8AqECI

    Works just as well on sales list using Status as it's filter:

    OnActivate()
    CurrForm.EDITABLE(TRUE);
    OnDeactivate()
    CurrForm.EDITABLE(FALSE);
    OnAfterValidate()
    CASE ViewStatus OF 
      ViewStatus::"View All":
        RESET;
      ViewStatus::"View Open":
        SETRANGE(Status,0);
      ViewStatus::"View Released":
        SETRANGE(Status,1);
    END;
    CurrForm.UPDATE;
    
    ViewStatus = global var - type option with options of: View All, View Open, View Released
    ps don't forget the VertGlue proprerty to bottom
  • coenecoene Member Posts: 6
    My problem is solved. Thanks for the help!
  • DenSterDenSter Member Posts: 8,305
Sign In or Register to comment.