Filter

From Zymonic

A filter captures data from the user using search fields and reports back matching results from a database table using report fields. It can be defined similarly to below:

  <Filter>
    <ZName>ts_fil_purchaserecords</ZName>
    <DisplayName>Purchase Records</DisplayName>
    <Category>Reports</Category>
    <ShortDescription>Shows all purchases</ShortDescription>
    <LongDescription>
      <p>Shows all of the purchase records</p>
    </LongDescription>
    <BaseTable>
      <ZName>ts_t_purchaserecords</ZName>
    </BaseTable>
    <FilterAction>
      <ZName>ts_fa_newpurchaserecord</ZName>
    </FilterAction>

    <!-- SearchFields -->
    <SearchField>
      <ZName>ts_sf_purchaseid</ZName>
    </SearchField>

    <!-- ReportFields -->
    <ReportField>
      <ZName>ts_rf_purchaseid_edit</ZName>
    </ReportField>
  </Filter>


Grouped Filters

A grouped filter has the results grouped by one of the fields, in a similar fashion to "group by" in SQL. This can be achieved simply by adding "GroupBy" to the filter, and referencing the group by in the report fields using "ApplyToGroups" like so:

  <Filter>
    ...
    <ReportField>
      <ZName>grouping_rf</ZName>
    ...
      <ApplyToGroups>gb_group</ApplyToGroups>
    </ReportField>
    <GroupBy>
      <ZName>gb_group</ZName>
      <DisplayName>Grouping</DisplayName>
      <TargetField>grouping_rf</TargetField>
    </GroupBy>
  </Filter>

The GroupBy XMLs can also be nested, resulting in what is known as a 'tree-view' filter. By default this displays as a series of collapsed groups that can be expanded/collapsed using JS +/- buttons, each with a group header at the top.

This XML:

  <GroupBy>
      <ZName>gb_group</ZName>
      <TargetField>grouping_rf</TargetField>
      <DisplayName>Grouping</DisplayName>
      <GroupBy>
        <ZName>gb_group_level_2</ZName>
        <DisplayName>Group level 2</DisplayName>
        <TargetField>id_rf</TargetField>
      </GroupBy>
  </GroupBy>


Produces:

(Add picture)


Additional Flags:

<ShowCount>true</ShowCount>

Added to a "GroupBy" to force the filter to use that level of grouping to calculate the filter count. For example, if you had 2 results for the top level group, with 3 results in each, which in turn also had 3 results, the filter count would say "2". Adding "ShowCount" to the bottom leve group will cause the count to be shown as "18".

<GroupExpanded>gb_group</GroupExpanded>

Added at the filter level and references a GroupBy, this will cause that group to be automatically expanded when the filter is run.


<ForceStandard>true</ForceStandard>

Added at the filter level, this flag will cause the filter to be displayed as a normal filter, without the "tree-view" JS.


<GroupHeadersAfter>true</GroupHeadersAfter>

Added at the filter level, this flag will cause the group headers to be displayed below the results in the groups.