Grid filters in code-behind

  1. #1

    Grid filters in code-behind

    I want to set gridfilters in codebehind (Page load), is this possible?

  2. #2

    RE: Grid filters in code-behind


    yes, sure, it is possible.
    What kind of problems do you have with GridFilters in code-behind?

    Vladimir Shcheglov
    Sr. Developer
  3. #3

    RE: Grid filters in code-behind

    I just don't know how to do it, and I can't find any examples :-)
  4. #4

    RE: Grid filters in code-behind

    Hi petlun,

    Please see the following code
    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Collections.ObjectModel" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    <html xmlns="">
    <head id="Head1" runat="server">
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
                GridFilters filters = new GridFilters();
                filters.Local = true;
                NumericFilter nf = new NumericFilter();
                nf.DataIndex = "Id";
                StringFilter sf = new StringFilter();
                sf.DataIndex = "Company";
                NumericFilter nf1 = new NumericFilter();
                nf1.DataIndex = "Price";
                DateFilter df = new DateFilter();
                df.DataIndex = "Date";
                df.DatePickerOptions.TodayText = "Now";
                ListFilter lf = new ListFilter();
                lf.DataIndex = "Size";
                lf.Options = "extra small,small,medium,large,extra large".Split(',');
                BooleanFilter bf = new BooleanFilter();
                bf.DataIndex = "Visible";
                this.Store1.DataSource = FiltersTestData.Data;
        <ext:ScriptManager ID="ScriptManager1" runat="server" StateProvider="None" />
        <h1>GridPanel with Local Filtering, Sorting and Paging</h1>
        <p>Please see column header menu for apllying filters</p>
        <ext:Store runat="server" ID="Store1" AutoLoad="true" RemoteSort="true">
                <ext:JsonReader ReaderID="Id">
                        <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="Y-m-dTh:i:s" />
                        <ext:RecordField Name="Size" Type="String" />
                        <ext:RecordField Name="Visible" Type="Boolean" />
            <SortInfo Field="Company" Direction="ASC" />
                <ext:FitLayout ID="FitLayout1" runat="server">
                    <ext:GridPanel runat="server" ID="GridPanel1" Border="false" StoreID="Store1">
                        <ColumnModel ID="ColumnModel1" runat="server">
                                <ext:Column Header="Id" DataIndex="Id" Sortable="true" />
                                <ext:Column Header="Company" DataIndex="Company" Sortable="true" />
                                <ext:Column Header="Price" DataIndex="Price" Sortable="true">
                                    <Renderer Format="UsMoney" />
                                <ext:Column Header="Date" DataIndex="Date" Sortable="true" Align="Center">
                                    <Renderer Fn="Ext.util.Format.dateRenderer('Y-m-d')" />
                                <ext:Column Header="Size" DataIndex="Size" Sortable="true" />
                                <ext:Column Header="Visible" DataIndex="Visible" Sortable="true" Align="Center">
                                    <Renderer Handler="return (value) ? 'Yes':'No';" />
                        <LoadMask ShowMask="true" />
                            <ext:PagingToolBar ID="PagingToolBar1" runat="server" PageSize="10"  />

    Vladimir Shcheglov
    Sr. Developer
  5. #5

    RE: Grid filters in code-behind

    Thanks vladimir for your answer.

    But I want to know how to set the actual filter values. What I'm trying to achieve save the filter for the grid/page and reload them on next visit.

    Best regards

Similar Threads

  1. [Razor] Example for grid filters
    By Natalie in forum 2.x Help
    Replies: 4
    Last Post: Apr 23, 2012, 10:22 AM
  2. Replies: 3
    Last Post: Jan 12, 2012, 4:26 PM
  3. [CLOSED] Hidden Change and Grid Filters are not working after Grid Reconfigure
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 15
    Last Post: Oct 16, 2011, 2:12 PM
  4. [CLOSED] Grid Filters Dynamic
    By majunior in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 18, 2011, 4:49 PM
  5. Replies: 16
    Last Post: Feb 23, 2011, 11:03 AM

Posting Permissions