Filter - AppDaddy-Software-Solutions-Inc/framework-markup-language GitHub Wiki
FILTER : Widget
A FILTER
is always a child of a Datasource. Datasource rows are filtered by applying an the filter eval
expression on each row in the datsource. Only rows that equte to true
are retained.
The FILTER
is useful for removing data from a Datasource that is not relevant or would be a hinderance to the widget you are supplying the data to.
For filters that involve multiple fields or complex logic, consider using an <EVAL/> transform ahead of the <FILTER/> in order to generate a calculated field on which to filter.
The filter can only filter fields in the data using boolean eval expressions with comparison operators
Name | Type | Default | Description | Req |
---|---|---|---|---|
filter | eval string | "" | boolean expression to evaluate and filter against | ✔ |
enabled | bool | "true" | boolean expression to (en/dis)able filter | ✔ |
<FML>
<!-- We used a DATA datasource but any datasource can be used
Filter can be applied to the original data source or to a subset
DATA datasource as we have done here -->
<DATA id="People" root="SET.ROW">
<value>
<![CDATA[
<SET>
<ROW>
<NAME>Avery Alberton</NAME>
<COUNTRY>United States</COUNTRY>
<CITY>Chicago</CITY>
</ROW>
<ROW>
<NAME>Ben Bordeau</NAME>
<COUNTRY>Canada</COUNTRY>
<CITY>Kingston</CITY>
</ROW>
<ROW>
<NAME>Davey Downie</NAME>
<COUNTRY>United States</COUNTRY>
<CITY>Rochester</CITY>
</ROW>
<ROW>
<NAME>Jim Jaimison</NAME>
<COUNTRY>Canada</COUNTRY>
<CITY>Ottawa</CITY>
</ROW>
<ROW>
<NAME>Samantha Smith</NAME>
<COUNTRY>Canada</COUNTRY>
<CITY>Kingston</CITY>
</ROW>
<ROW>
<NAME>Orville Richard Burrell</NAME>
<COUNTRY>Jamaica</COUNTRY>
<CITY>Kingston</CITY>
</ROW>
</SET>
]]>
</value>
<DATA id="Canadians">
<FILTER filter="={data.COUNTRY} == 'Canada'" />
</DATA>
<DATA id="Kingstonians">
<FILTER filter="={data.CITY} == 'Kingston'" />
</DATA>
<DATA id="KingstonCA">
<FILTER filter="={data.COUNTRY} == 'Canada' && {data.CITY} == 'Kingston'" />
</DATA>
</DATA>
<CENTER>
<TEXT value="Canadians" />
<SELECT id="sel1" data="Canadians">
<OPTION value="{data.NAME}" />
</SELECT>
<PAD top="10" />
<TEXT value="Kingstonians" />
<SELECT id="sel2" data="Kingstonians">
<OPTION value="{data.NAME}" />
</SELECT>
<PAD top="10" />
<TEXT value="Canadian Kingstonians" />
<SELECT id="sel3" data="KingstonCA">
<OPTION value="{data.NAME}" />
</SELECT>
</CENTER>
</FML>
<FML>
<ICONS id="icons">
<FILTER filter="noe('{filter}') || contains('{data.icon}','{filter}')"/>
</ICONS>
<ROW>
<VAR id="filter"/>
<INPUT id="f" length="100" debounce="1" hint="Search Filter"/>
<BUTTON label="find" enabled="=!noe({f})" type="elevated" height="55" color="green" onclick="filter.set('{f}')"/>
</ROW>
<LIST data="icons">
<ITEM id="item" width="250" height="250" color="white" center="true" margin="10" radius="25">
<ROW align="left" margin="0,0,0,20">
<TEXT value="#" bold="true" color="black" selectable="true" size="10"/>
<TEXT value="{item.index}" bold="true" color="black" selectable="true" size="12"/>
</ROW>
<BOX expand="false" elevation="6" color="white" pad="25">
<ICON value="{data.icon}" color="#92CDF1" size="75"/>
</BOX>
<TEXT value="{data.icon}" bold="true" color="black" margin="10" selectable="true"/>
</ITEM>
</LIST>
</FML>