1. OG data type - OGFilter

    Article: AN0001714Updated:

    This object enables to set filter conditions for a class/query. It is used for creation of a filter from script and following record reading.

    Object properties

    Name Description
    void Add(bool andOr, string columnCode, string oper) Method adds a new condition.
    void Add(bool andOr, string columnCode, string oper, object data) Method adds a new condition.
    void Add(int? parentIndex, bool andOr, string columnCode, string oper) Method adds a new condition.
    void Add(int? parentIndex, bool andOr, string columnCode, string oper, object data) Method adds a new condition.
    int AddBracket( bool andOr) Method adds a new bracket condition into the filter.
    int AddBracket(int? parentIndex, bool andOr) Method adds a new bracket condition into the filter.
    void Clear() Method clears the filter.
    void Run() Method clears the filter.
    void Minimize() Method maximizes filter block on page Datas.aspx.
    void Maximize() Method minimizes filter block on page Datas.aspx.

    Conditions are added one after another. In order to nest a condition add first a bracket by means of AddBracket method. For a nested condition you have to set parameter parentIndex, that represents index of superior condition/bracket.

    Also particular brackets can be nested.

    Parameter andOr defines operator AND and OR for the currently inserted condition and previous condition. This parameter is irrellevant in case of the very first condition or the first condition in the bracket. Value true means operator AND, value false means operator OR.

    Method Clear clears the filter but does not start application of no filter on records. For this you have to call function Run.

     Operators

    The following table displays list of allowed operators. Both the first and second type can be used when defining condition in script. The second type is determined also for the filter definition in URL (certain characters are not allowed in URL). 

    Type 1 Type 2 Operator
    = EQ equal to
    != NEQ not equal to
    > GT greater than
    >= GE greater than or equal to
    < LT less than
    <= LE less than or equal to
    contains CONTAINS contains
    not contains NOTCONTAINS does not contain
    in interval ININTERVAL in interval
    start with STARTWITH begins with
    end with ENDWITH ends with
    not start with NOTSTARTWITH does not begin with
    not end with NOTENDWITH does not end with
    is null ISNULL is null
    is not null ISNOTNULL is not null
    < [kb] LTKB file size is less than
    > [kb] GTKB file size is greator than
    = (column) COLUMNEQ equal to - comparing two columns
    != (column) COLUMNNEQ not equal to - comparing two columns
    < (column) COLUMNLT less than - comparing two columns
    <= (column) COLUMNLE less than or equal to - comparing two columns
    > (column) COLUMNGT greater than - comparing two columns
    >= (column) COLUMNGE greater than or equal to - comparing two columns
    = (length) LENEQ equal to - length of text
    != (length) LENNEQ not equal to - length of text
    < (length) LENLT less than - length of text
    <= (length) LENLE less than or equal to - length of text
    > (length) LENGT greater than - length of text
    >= (length) LENGE greater than or equal to - length of text

     Data parameter

     Parameter data is filled in for some types of conditions:

    • for comparing two columns enter the code of the other column
    • for data column enter a date
    • for classlink enter one of these values: ID (int), Person, PersonInfo, EntityInfo, DataRow, string

    If you enter a string, than for column of the type User users will be searched by their account. For column of the type reference to a class ObjectGears will look for column with code "code" and search required records in it.

    Only perfect match is accepted when comparing this parameter.

    Example

    This example clears the filtering block and inserts a condition, that filters records, that have in column shorttext1 a text with max. length 4 characters. After that it minimizes the filter block and runs the filter.

    OGFilter.Clear();
    OGFilter.Add( true, 'shorttext1', '< (length)', 4);
    OGFilter.Maximize();

    OGFilter.Run();

    This example displays records assigned to the current user with status new or testing.

    OGFilter.Clear();
    OGFilter.Add( true, 'assignto', '=', OG.Person.GetLoginPerson());

    var stavIndex = OGFilter.AddBracket( true);
    OGFilter.Add( stavIndex, false, 'status', '=', 'new');
    OGFilter.Add( stavIndex, false, 'status', '=', 'testing');

    OGFilter.Run();

×