Jun 29, 2015, 8:33 AM
Grid Filter
how i can add GridFilters to grid panel Using c# Code
For Dynamic purpose
Plz Help me
GridFilterCollection
, for example:<%@ Page Language="C#" %>
<%@ Import Namespace="System.Collections.ObjectModel" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
// the ListFilter for column Size is added in code instead of in markup:
// <ext:ListFilter DataIndex="Size" Options="extra small,small,medium,large,extra large" />
ListFilter listFilter = new ListFilter();
listFilter.DataIndex = "Size";
listFilter.Options = new string[] { "extra small", "small", "medium", "large", "extra large" };
this.GridFilters1.Filters.Add(listFilter);
this.Store1.DataSource = ExtNet1.July2015.FiltersTestData.Data;
this.Store1.DataBind();
}
}
</script>
<!DOCTYPE>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Store runat="server" ID="Store1">
<Reader>
<ext:JsonReader IDProperty="Id">
<Fields>
<ext:RecordField Name="Id" Type="Int" />
<ext:RecordField Name="Company" Type="String" />
<ext:RecordField Name="Price" Type="Float" />
<ext:RecordField Name="Date" Type="Date" DateFormat="yyyy-MM-ddTHH:mm:ss" />
<ext:RecordField Name="Size" Type="String" />
<ext:RecordField Name="Visible" Type="Boolean" />
</Fields>
</ext:JsonReader>
</Reader>
<SortInfo Field="Company" Direction="ASC" />
</ext:Store>
<ext:Window
ID="Window1"
runat="server"
Width="700"
Height="400"
Closable="false"
Collapsible="true"
Title="Example"
Maximizable="true"
Layout="Fit">
<Items>
<ext:GridPanel runat="server" ID="GridPanel1" Border="false" StoreID="Store1">
<ColumnModel runat="server">
<Columns>
<ext:Column Header="Id" DataIndex="Id" />
<ext:Column Header="Company" DataIndex="Company" />
<ext:Column Header="Price" DataIndex="Price">
<Renderer Format="UsMoney" />
</ext:Column>
<ext:DateColumn Header="Date" DataIndex="Date" Align="Center" Format="yyyy-MM-dd" />
<ext:Column Header="Size" DataIndex="Size" />
<ext:Column Header="Visible" DataIndex="Visible" Align="Center">
<Renderer Handler="return (value) ? 'Yes':'No';" />
</ext:Column>
</Columns>
</ColumnModel>
<LoadMask ShowMask="true" />
<Plugins>
<ext:GridFilters runat="server" ID="GridFilters1" Local="true">
<Filters>
<ext:NumericFilter DataIndex="Id" />
<ext:StringFilter DataIndex="Company" />
<ext:NumericFilter DataIndex="Price" />
<ext:DateFilter DataIndex="Date">
<DatePickerOptions runat="server" TodayText="Now" />
</ext:DateFilter>
<ext:BooleanFilter DataIndex="Visible" />
</Filters>
</ext:GridFilters>
</Plugins>
</ext:GridPanel>
</Items>
</ext:Window>
</body>
</html>
The above sample demonstrates how to add a ListFilter
in code instead of in markup. You can apply the same solution for other filter types, too.