New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
Accessing Expression Items
Updated over 6 months ago
Accessing Items
RadFilter exposes the ExpressionItemCreated event which is fired after each item creation.It provides a more easy and intuitive way of accessing the filter expression items. Depending on expressionthat was created the item in the arguments could be either RadFilterSingleExpressionItem or RadFilterGroupExpression.
Below is a sample code implementation which demonstrates how you can manipulate the filter items. The code logic forbids the creation of sub-group expressions by hiding the AddGroupExpressionButton and populates the RadFilterDropDownEditor with data.
ASPNET
<div class="filterDiv">
<telerik:RadFilter RenderMode="Lightweight" runat="server" ID="RadFilter1" FilterContainerID="RadGrid1" ShowApplyButton="true"
OnExpressionItemCreated="RadFilter1_ExpressionItemCreated">
<FieldEditors>
<telerik:RadFilterDropDownEditor FieldName="ShipCountry" DataTextField="ShipCountry"
DataValueField="ShipCountry" />
</FieldEditors>
</telerik:RadFilter>
</div>
<telerik:RadGrid RenderMode="Lightweight" runat="server" ID="RadGrid1" AutoGenerateColumns="false" DataSourceID="SqlDataSource1"
AllowPaging="true" AllowSorting="true" AllowFilteringByColumn="true">
<MasterTableView IsFilterItemExpanded="false" CommandItemDisplay="Top">
<Columns>
<telerik:GridNumericColumn DataField="OrderID" HeaderText="OrderID" DataType="System.Int32">
</telerik:GridNumericColumn>
<telerik:GridDateTimeColumn DataField="OrderDate" HeaderText="OrderDate" DataFormatString="{0:MM/dd/yyyy}">
</telerik:GridDateTimeColumn>
<telerik:GridNumericColumn DataField="ShipVia" HeaderText="ShipVia" DataType="System.Int32">
</telerik:GridNumericColumn>
<telerik:GridBoundColumn DataField="ShipName" HeaderText="ShipName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ShipAddress" HeaderText="ShipAddress">
</telerik:GridBoundColumn>
<telerik:GridNumericColumn DataField="Freight" HeaderText="Freight" DataType="System.Decimal">
</telerik:GridNumericColumn>
<telerik:GridNumericColumn DataField="ShipCountry" HeaderText="ShipCountry">
</telerik:GridNumericColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="Select OrderID, OrderDate, ShipVia, ShipName, ShipAddress, Freight, ShipCountry FROM Orders">
</asp:SqlDataSource>In the tables below are listed the properties of the expression items according to the type.
RadFilterExpressionItem
| Property | Description |
|---|---|
| FunctionalInterfaceContainer | Gets the container holding the links menu - the GroupOperation(for RadFilterGroupExpressionItem), FilterFunction and the editor FieldName. |
| ToolsInterfaceContainer | Gets the container holding item specific controls. An input control for the RadFilterSingleExpressionItem and AddGroupExpression, AddItemExpression for the RadFilterGroupExpressionItem. |
| RemoveButton | Gets a reference to the remove button which removes an expression from the RadFilter expression tree. |
RadFilterGroupExpressionItem
| Property | Description |
|---|---|
| GroupOperationChooserLink | Gets the HyperLink control which chooses the item expression GroupOperation value |
| AddExpressionButton | Gets the LinkButton control which adds a new RadFilterSingleExpressionItem to the RadFilter expression items tree |
| AddGroupExpressionButton | Gets the LinkButton control which adds a new RadFilterGroupExpressionItem to the RadFilter expression items tree |
RadFilterSingleExpressionItem
| Property | Description |
|---|---|
| FieldName | Gets the associated RadFilterNonGroupExpression.FieldName value |
| IsSingleValue | Gets a value indicating if the expression item have only one value. If the property returns true the InputControl value will not be null |
| IsDoubleValue | Gets a value indicating if the expression item have two values (between filtering is performed). If the property returns true the SecondInputControl value will not be null |
| InputControl | The input control which determines an expression value. The property could return null if the Expression is not of type IRadFilterValueExpression |
| SecondInputControl | The second input control which determines the second expression value when performing between filtering. The property will not return null only when performing between filtering |
| FieldNameChooserLink | Gets the HyperLink control which is used for choosing the FieldName |
| FilterFunctionChooserLink | Gets the HyperLink control which is used for choosing the FilterFunction |
| BetweenDelimeter | Gets the LiteralControl which is placed between the two input controls when the filter function is "Between" or "NotBetween" |