Filtering not happening

Page 1 of 2 12 LastLast
  1. #1

    Filtering not happening

    Hi,

    I've added filtering in gridpanel. Here is my code. Can someone assist pls?

    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager runat="server">
        </ext:ResourceManager>
        <ext:Store runat="server" ID="store1">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="CAPABILITY_ZONE_ID">
                        </ext:RecordField>
                        <ext:RecordField Name="CAPABILITY_ZONE_NAME">
                        </ext:RecordField>
                        <ext:RecordField Name="CAPABILITY_ZONE_DESC">
                        </ext:RecordField>
                        <ext:RecordField Name="COUNTRY_ID">
                        </ext:RecordField>
                        <ext:RecordField Name="NETWORK_LOCATION_ID">
                        </ext:RecordField>
                        <ext:RecordField Name="NETWORK_LOCATION_NAME">
                        </ext:RecordField>
                        <ext:RecordField Name="CAPABILITY_VALID_CD">
                        </ext:RecordField>
                        <ext:RecordField Name="CREATED_BY">
                        </ext:RecordField>
                        <ext:RecordField Name="CREATED_DATE">
                        </ext:RecordField>
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <SortInfo Field="CAPABILITY_ZONE_NAME" Direction="ASC" />
        </ext:Store>
        <ext:GridPanel runat="server" StripeRows="true" ID="grdPanel" StoreID="store1" Height="550"
            Width="500" Title="Supplier Details">
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column ColumnID="ZONE_ID" Header="ZONE_ID" DataIndex="CAPABILITY_ZONE_ID">
                    </ext:Column>
                    <ext:Column ColumnID="ZONE_NAME" Header="ZONE_NAME" DataIndex="CAPABILITY_ZONE_NAME">
                    </ext:Column>
                    <ext:Column ColumnID="ZONE_DESC" Header="ZONE_DESC" DataIndex="CAPABILITY_ZONE_DESC">
                    </ext:Column>
                    <ext:Column ColumnID="COUNTRY_ID" Header="COUNTRY_ID" DataIndex="COUNTRY_ID">
                    </ext:Column>
                    <ext:Column ColumnID="LOCATION_ID" Header="LOCATION_ID" DataIndex="NETWORK_LOCATION_ID">
                    </ext:Column>
                    <ext:Column ColumnID="LOCATION_NAME" Header="LOCATION_NAME" DataIndex="NETWORK_LOCATION_NAME">
                    </ext:Column>
                    <ext:Column ColumnID="VALID_CD" Header="VALID_CD" DataIndex="CAPABILITY_VALID_CD">
                    </ext:Column>
                    <ext:Column ColumnID="CREATED_BY" Header="CREATED_BY" DataIndex="CREATED_BY">
                    </ext:Column>
                    <ext:Column ColumnID="CREATED_DATE" Header="CREATED_DATE" DataIndex="CREATED_DATE">
                    </ext:Column>
                </Columns>
            </ColumnModel>
            <Plugins>
                <ext:GridFilters runat="server" ID="GridFilters1">
                    <Filters>
                        <ext:StringFilter DataIndex="CAPABILITY_ZONE_ID">
                        </ext:StringFilter>
                        <ext:StringFilter DataIndex="CAPABILITY_ZONE_NAME">
                        </ext:StringFilter>
                        <ext:StringFilter DataIndex="CAPABILITY_ZONE_DESC">
                        </ext:StringFilter>
                        <ext:StringFilter DataIndex="COUNTRY_ID">
                        </ext:StringFilter>
                        <ext:StringFilter DataIndex="NETWORK_LOCATION_ID">
                        </ext:StringFilter>
                        <ext:StringFilter DataIndex="NETWORK_LOCATION_NAME">
                        </ext:StringFilter>
                        <ext:StringFilter DataIndex="CAPABILITY_VALID_CD">
                        </ext:StringFilter>
                        <ext:StringFilter DataIndex="CREATED_BY">
                        </ext:StringFilter>
                        <ext:StringFilter DataIndex="CREATED_DATE">
                        </ext:StringFilter>
                    </Filters>
                </ext:GridFilters>
            </Plugins>
        </ext:GridPanel>
        </form>
    </body>
    Last edited by Baidaly; Dec 10, 2012 at 11:23 PM. Reason: Please, use [CODE] tag
  2. #2
    Hello!

    Does filter plugin request new data from the Server Side or you have an exception on the Client side?
  3. #3
    Quote Originally Posted by Baidaly View Post
    Hello!

    Does filter plugin request new data from the Server Side or you have an exception on the Client side?
    HI,

    filter plugin will take data from store, which takes data from database.
  4. #4
    Can someone help here. My requirement is, I've a gridpanel and datas will be populated from database via <store>. I need filtering and grouping as well. Some sample code will be much appreciated
  5. #5
    Quote Originally Posted by Aswini Ladish View Post
    Can someone help here. My requirement is, I've a gridpanel and datas will be populated from database via <store>. I need filtering and grouping as well. Some sample code will be much appreciated
    Hi,

    this is quite urgent. Can someone help ?
  6. #6
    Try to set Local=false for GridFilters
  7. #7
    Quote Originally Posted by Vladimir View Post
    Try to set Local=false for GridFilters
    Even, after setting its not working
  8. #8
    Please provide runable test sample
  9. #9
    here is the code
    Last edited by Aswini Ladish; Dec 13, 2012 at 5:03 AM.
  10. #10
    Quote Originally Posted by Vladimir View Post
    Please provide runable test sample

    Quote Originally Posted by Vladimir View Post
    Please provide runable test sample
    I've attached the sample code.
    Below is .aspx page
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="GridControls.WebForm1" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Grid Panel example</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <ext:ResourceManager runat="server">
    </ext:ResourceManager>
    <ext:GridPanel runat="server" StripeRows="true" ID="grdPanel" Height="550"
    Width="500" Title="Supplier Details">
    <Store>
    <ext:Store runat="server" ID="store1" OnRefreshData="Store1_RefreshData">
    <Proxy>
    <%--<ext:PageProxy />--%>
    </Proxy>
    <Reader>
    <ext:JsonReader IDProperty="CAPABILITY_ZONE_ID">
    <Fields>
    <ext:RecordField Name="CAPABILITY_ZONE_ID">
    </ext:RecordField>
    <ext:RecordField Name="CAPABILITY_ZONE_NAME">
    </ext:RecordField>
    <ext:RecordField Name="CAPABILITY_ZONE_DESC">
    </ext:RecordField>
    <ext:RecordField Name="COUNTRY_ID">
    </ext:RecordField>
    <ext:RecordField Name="NETWORK_LOCATION_ID">
    </ext:RecordField>
    <ext:RecordField Name="NETWORK_LOCATION_NAME">
    </ext:RecordField>
    <ext:RecordField Name="CAPABILITY_VALID_CD">
    </ext:RecordField>
    <ext:RecordField Name="CREATED_BY">
    </ext:RecordField>
    <ext:RecordField Name="CREATED_DATE">
    </ext:RecordField>
    </Fields>
    </ext:JsonReader>
    </Reader>
    <%-- <BaseParams>
    <ext:Parameter Name="start" Value="0" Mode="Raw" />
    <ext:Parameter Name="limit" Value="10" Mode="Raw" />
    <ext:Parameter Name="sort" Value="" />
    <ext:Parameter Name="dir" Value="" />
    </BaseParams>--%>
    <SortInfo Field="CAPABILITY_ZONE_NAME" Direction="ASC" />
    </ext:Store>
    </Store>
    <ColumnModel runat="server">
    <Columns>
    <ext:Column ColumnID="ZONE_ID" Header="ZONE_ID" DataIndex="CAPABILITY_ZONE_ID">
    </ext:Column>
    <ext:Column ColumnID="ZONE_NAME" Header="ZONE_NAME" DataIndex="CAPABILITY_ZONE_NAME">
    </ext:Column>
    <ext:Column ColumnID="ZONE_DESC" Header="ZONE_DESC" DataIndex="CAPABILITY_ZONE_DESC">
    </ext:Column>
    <ext:Column ColumnID="COUNTRY_ID" Header="COUNTRY_ID" DataIndex="COUNTRY_ID">
    </ext:Column>
    <ext:Column ColumnID="LOCATION_ID" Header="LOCATION_ID" DataIndex="NETWORK_LOCATION_ID">
    </ext:Column>
    <ext:Column ColumnID="LOCATION_NAME" Header="LOCATION_NAME" DataIndex="NETWORK_LOCATION_NAME">
    </ext:Column>
    <ext:Column ColumnID="VALID_CD" Header="VALID_CD" DataIndex="CAPABILITY_VALID_CD">
    </ext:Column>
    <ext:Column ColumnID="CREATED_BY" Header="CREATED_BY" DataIndex="CREATED_BY">
    </ext:Column>
    <ext:Column ColumnID="CREATED_DATE" Header="CREATED_DATE" DataIndex="CREATED_DATE">
    </ext:Column>
    </Columns>
    </ColumnModel>
    <Plugins>
    <ext:GridFilters runat="server" ID="GridFilters1">
    <Filters>
    <ext:StringFilter DataIndex="CAPABILITY_ZONE_ID">
    </ext:StringFilter>
    <ext:StringFilter DataIndex="CAPABILITY_ZONE_NAME">
    </ext:StringFilter>
    <ext:StringFilter DataIndex="CAPABILITY_ZONE_DESC">
    </ext:StringFilter>
    <ext:StringFilter DataIndex="COUNTRY_ID">
    </ext:StringFilter>
    <ext:StringFilter DataIndex="NETWORK_LOCATION_ID">
    </ext:StringFilter>
    <ext:StringFilter DataIndex="NETWORK_LOCATION_NAME">
    </ext:StringFilter>
    <ext:StringFilter DataIndex="CAPABILITY_VALID_CD">
    </ext:StringFilter>
    <ext:StringFilter DataIndex="CREATED_BY">
    </ext:StringFilter>
    <ext:StringFilter DataIndex="CREATED_DATE">
    </ext:StringFilter>
    </Filters>
    </ext:GridFilters>
    </Plugins>
    </ext:GridPanel>
    </form>
    </body>
    </html>
    Below is the .cs file
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data.OracleClient;
    using System.Data;
    using Ext.Net;
    using System.Configuration;
    namespace GridControls
    {
    public partial class WebForm1 : System.Web.UI.Page
    {
    OracleDataAdapter da;
    DataSet ds = new DataSet();
    Supplier sup = new Supplier();
    List<Supplier> data;
    protected void Page_Load(object sender, EventArgs e)
    {
    
    if (!X.IsAjaxRequest)
    {
    this.store1.DataSource = this.GetConnection();
    this.store1.DataBind();
    }
    //grdPanel.Render();
    }
    public DataSet GetConnection()
    {
    string conStr;
    conStr = ConfigurationManager.ConnectionStrings["PGFEConnection"].ConnectionString.Trim();
    OracleConnection conn = new OracleConnection(conStr);
    //OracleCommand cmd;
    try
    {
    conn.Open();
    da = new OracleDataAdapter("Select * from capability_zones", conn);
    da.Fill(ds);
    data = sup.ConvertDateIntoList(ds);
    return ds;
    }
    catch (Exception ex)
    { return null; }
    finally
    {
    //conn.Close();
    }
    }
    protected void Store1_RefreshData(object sender, StoreRefreshDataEventArgs e)
    {
    //List<object> data = FiltersTestData.Data;
    
    //List<DataRow> data = ds.Tables["capability_zones"].AsEnumerable().ToList();
    string s = e.Parameters[this.GridFilters1.ParamPrefix];
    //or with hardcoding - string s = e.Parameters["gridfilters"];;
    //DataTable dt = new DataTable();
    // dt.Load(dr);
    //List<int> listItem = new List<int>();
    //while (dr.Read())
    //{
    // for (int i = 0; i < dr.FieldCount; i++)
    // {
    // listItem.Add(i);
    // }
    //}
    //-- start filtering ------------------------------------------------------------
    if (!string.IsNullOrEmpty(s))
    {
    FilterConditions fc = new FilterConditions(s);
    foreach (FilterCondition condition in fc.Conditions)
    {
    Comparison comparison = condition.Comparison;
    string field = condition.Name;
    FilterType type = condition.FilterType;
    object value;
    switch (condition.FilterType)
    {
    case FilterType.Boolean:
    value = condition.ValueAsBoolean;
    break;
    case FilterType.Date:
    value = condition.ValueAsDate;
    break;
    case FilterType.List:
    value = condition.ValuesList;
    break;
    case FilterType.Numeric:
    if (data.Count > 0 && data[0].GetType().GetProperty(field).PropertyType == typeof(int))
    {
    value = condition.ValueAsInt;
    }
    else
    {
    value = condition.ValueAsDouble;
    }
    break;
    case FilterType.String:
    value = condition.Value;
    break;
    default:
    throw new ArgumentOutOfRangeException();
    }
    data.RemoveAll(
    item =>
    {
    object oValue = item.GetType().GetProperty(field).GetValue(item, null);
    IComparable cItem = oValue as IComparable;
    switch (comparison)
    {
    case Comparison.Eq:
    switch (type)
    {
    case FilterType.List:
    return !(value as ReadOnlyCollection<string>).Contains(oValue.ToString());
    case FilterType.String:
    return !oValue.ToString().StartsWith(value.ToString());
    default:
    return !cItem.Equals(value);
    }
    case Comparison.Gt:
    return cItem.CompareTo(value) < 1;
    case Comparison.Lt:
    return cItem.CompareTo(value) > -1;
    default:
    throw new ArgumentOutOfRangeException();
    }
    }
    );
    }
    }
    //-- start sorting ------------------------------------------------------------
    //if (!string.IsNullOrEmpty(e.Sort))
    //{
    // data.Sort(delegate(Supplier x, Supplier y)//(delegate(object x, object y)
    // {
    // object a;
    // object b;
    // int direction = e.Dir == Ext.Net.SortDirection.DESC ? -1 : 1;
    // a =x.GetType().GetProperty(e.Sort).GetValue(x, null);
    // b = y.GetType().GetProperty(e.Sort).GetValue(y, null);
    // return CaseInsensitiveComparer.Default.Compare(a, b) * direction;
    // });
    //}
    //-- end sorting ------------------------------------------------------------
    
    //-- start paging ------------------------------------------------------------
    var limit = e.Limit;
    if ((e.Start + e.Limit) > data.Count)
    {
    limit = data.Count - e.Start;
    }
    List<Supplier> rangeData = (e.Start < 0 || limit < 0) ? data : data.GetRange(e.Start, limit);
    //-- end paging ------------------------------------------------------------
    //The Total can be set in RefreshData event as below
    //or (Store1.Proxy.Proxy as PageProxy).Total in anywhere
    //Please pay attention that the Total make a sence only during DirectEvent because
    //the Store with PageProxy get/refresh data using ajax request
    e.Total = data.Count;
    this.grdPanel.GetStore().DataSource = data;
    }
    //////////////////
    
    }
    }
    Below is BAL.cs file
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Data;
    namespace GridControls
    {
    public class BAL
    {
    }
    public class Supplier
    {
    public DataSet dset; 
    public Supplier(){}
    public int CAPABILITY_ZONE_ID
    { get; set; }
    public string CAPABILITY_ZONE_NAME
    { get; set; }
    public string CAPABILITY_ZONE_DESC
    { get; set; }
    public int COUNTRY_ID
    { get; set; }
    public int NETWORK_LOCATION_ID
    { get; set; }
    public string NETWORK_LOCATION_NAME
    { get; set; }
    public int CAPABILITY_VALID_CD
    { get; set; }
    public string CREATED_BY
    { get; set; }
    public string CREATED_DATE
    { get; set; }
     
    public List<Supplier> ConvertDateIntoList(DataSet ds)
    {
    dset = ds;
    var suppList = new List<Supplier>();
    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
    {
    suppList.Add(new Supplier()
    {
    CAPABILITY_ZONE_ID = Convert.ToInt32(ds.Tables[0].Rows[i][0] == DBNull.Value ? 0 : ds.Tables[0].Rows[i][0]),
    CAPABILITY_ZONE_NAME = ds.Tables[0].Rows[i][1].ToString(),
    CAPABILITY_ZONE_DESC = ds.Tables[0].Rows[i][2].ToString(),
    COUNTRY_ID = Convert.ToInt32(ds.Tables[0].Rows[i][3] == DBNull.Value ? 0 : ds.Tables[0].Rows[i][3]),
    NETWORK_LOCATION_ID = Convert.ToInt32(ds.Tables[0].Rows[i][4] == DBNull.Value ? 0 : ds.Tables[0].Rows[i][4]),
    NETWORK_LOCATION_NAME = ds.Tables[0].Rows[i][5].ToString(),
    CAPABILITY_VALID_CD = Convert.ToInt32(ds.Tables[0].Rows[i][6] == DBNull.Value ? 0 : ds.Tables[0].Rows[i][6]),
    CREATED_BY = ds.Tables[0].Rows[i][7].ToString(),
    CREATED_DATE = ds.Tables[0].Rows[i][8].ToString()
    });
    
    }
    return suppList;
    }
    public static List<object> Data
    {
    get
    {
    var suppData = new List<object>();
    //foreach (DataRow dr in dset)
    //{
    // suppData.Add(new Supplier()
    // {
    // }
    // );
    //}
    return suppData;
    }
    }
    
    }
    }
    Last edited by Baidaly; Dec 13, 2012 at 6:08 AM. Reason: Please, use [CODE] tag
Page 1 of 2 12 LastLast

Similar Threads

  1. ComboBox Filtering Bug
    By amgw in forum 1.x Help
    Replies: 5
    Last Post: Nov 11, 2011, 4:57 PM
  2. File filtering
    By NishaLijo in forum 1.x Help
    Replies: 1
    Last Post: Jul 28, 2010, 11:03 PM
  3. Need help in filtering
    By syed2uk in forum 1.x Help
    Replies: 1
    Last Post: Jan 12, 2010, 5:36 AM
  4. backend filtering
    By marcmvc in forum 1.x Help
    Replies: 0
    Last Post: Nov 05, 2009, 5:06 PM
  5. [Q] Filtering time of the day?
    By plykkegaard in forum 1.x Help
    Replies: 0
    Last Post: Apr 06, 2009, 7:52 AM

Posting Permissions