Databases Reference
In-Depth Information
FIGURE 12.4
Product search page filtered by supplier country.
This page displays the Origin column using the
UnleashedField
and Parent field template
with markup shown here:
<unl:
UnleashedField
DataField=”Supplier”
UIHint=”Parent” DisplayField=”Country”/>
To implement the requirement of searching for products by their countries of origin, you
would like to use a similar pattern with markup that looks like this:
<unl:
UnleashedFilter
runat=”server” DataField=”Supplier”
FilterUIHint=”Parent” DisplayField=”Country”/>
In other words, the Parent
filter
template is also associated with the
Supplier
property of
the Product entity and displays the filter control for the
Country
property of the parent
Supplier entity.
As you can see in Listing 12.7, the approach used in the Parent filter template to locate
and instantiate a filter template appropriate for the parent property is also similar to the
one used to implement the
Parent
field template earlier. Its markup defines a nested
instance of the
UnleashedFilter
control that will be responsible for loading another filter
template based on the property of the parent entity specified as the
DisplayField
.
LISTING 12.7
Parent Filter Template (Markup)
<%@ Control Language=”C#” CodeBehind=”Parent.ascx.cs”
Inherits=”WebApplication.DynamicData.Filters.ParentFilter” %>
<unl:UnleashedFilter ID=”filter” runat=”server” OnInit=”Filter_Init”/>
Just like with the Parent field template, most of the implementation of the Parent filter
template is in its code-behind file. At a high-level, it is responsible for two things—initial-
izing the nested
UnleashedFilter
control with all information required to load the appro-
priate filter template for the parent entity property and implementing the query logic