GridFilters Plugin created from Code behind using HttpProxy

  1. #1

    GridFilters Plugin created from Code behind using HttpProxy

    Hi. I am trying to implement something very similar to this post:

    http://forums.ext.net/showthread.php...with-HttpProxy

    The only difference is all my gridpanel, store and gridfilter plugins are generated from code behind. Any help would be appreciated.

    I have the following code:
            private Store BuildStore(Trade_RecType rectype, string sDate)
            {
                JsonReader rdr = new JsonReader();
                PropertyInfo[] oProps = (typeof(TradeData)).GetProperties();
                foreach (PropertyInfo pi in oProps)
                {
                    Type colType = pi.PropertyType;
                        rdr.Fields.Add(pi.Name);
                }
                rdr.Root = "d.Data";
                rdr.TotalProperty = "d.TotalRecords";
                HttpProxy proxy = new HttpProxy() { Url = "DTCWebService.asmx/DataPagingFilter", Method = HttpMethod.POST, Json = true };
                Store store = new Store
                {
                    AutoLoad = true,
                    RemoteSort = true,
                    ClientIDMode = ClientIDMode.Static,
                    RemotePaging = true,
                    SortInfo = { Field = "dtcControlNum", Direction = ExtJS.SortDirection.ASC },
                    RemoteGroup = true
                };
    
                store.Reader.Add(rdr);
                store.Proxy.Add(proxy);
                store.AutoLoadParams.Add(new ExtJS.Parameter { Name = "strDtUpload", Value = sDate, Mode = ParameterMode.Value });
                store.AutoLoadParams.Add(new ExtJS.Parameter { Name = "rectype", Value = rectype.ToString(), Mode = ParameterMode.Value });
                store.AutoLoadParams.Add(new ExtJS.Parameter { Name = "start", Value = "0", Mode = ParameterMode.Raw });
                store.AutoLoadParams.Add(new ExtJS.Parameter { Name = "limit", Value = "25", Mode = ParameterMode.Raw });
                store.BaseParams.Add(new ExtJS.Parameter { Name = "strDtUpload", Value = sDate, Mode = ParameterMode.Value });
                store.BaseParams.Add(new ExtJS.Parameter { Name = "rectype", Value = rectype.ToString(), Mode = ParameterMode.Value });
                return store;
            }
    
            private GridPanel BuildGridPanel(Trade_RecType rectype, string sDate)
            {
                GridPanel grid = new GridPanel();
                ColumnCollection cols = dtcConfirmRepository.GetGridColumns(rectype);
                grid.ColumnLines = true;
    
                grid.Store.Add(this.BuildStore(rectype,sDate));
                grid.ColumnModel.Columns.AddRange(cols);
                grid.SelectionModel.Add(new RowSelectionModel() { SingleSelect = true });
                grid.LoadMask.Msg = "Loading...";
                grid.LoadMask.ShowMask = true;
                grid.BottomBar.Add(new PagingToolbar { PageSize = 25 });
                grid.Plugins.Add(GetGridFilters(rectype));
                grid.GetStore().BaseParams.Add(new ExtJS.Parameter { Name = "filter", Value = "#{" + grid.ID + "}.getFilterPlugin().buildQuery(#{"+grid.ID+"}.getFilterPlugin().getFilterData())", Mode = ParameterMode.Raw, Encode=true });
                return grid;
            }
    
            private GridFilters GetGridFilters(Trade_RecType rectype)
            {
                GridFilters filters = new GridFilters() { Local = false, Visible=true, ShowMenu=true };
                GridFilterCollection filterColl = new GridFilterCollection();
                filterColl.Add(new StringFilter { DataIndex="ControlNum"});
                filters.Filters.AddRange(filterColl);
                return filters;
            }
    Also what should I call my filter parameter in my webservice. I've seen posts to call it "gridfilters" while others say to call it "filter". I've tried both but neither one is working.

    Thank you.
  2. #2
    fyi,

    I fixed it by assigning an ID to my grid created in the code behind.

    private GridPanel BuildGridPanel(Trade_RecType rectype, string sDate)
    {
    GridPanel grid = new GridPanel();
    grid.ID = rectype.ToString();
    ColumnCollection cols = dtcConfirmRepository.GetGridColumns(rectype);
    grid.ColumnLines = true;

    grid.Store.Add(this.BuildStore(rectype,sDate));
    grid.ColumnModel.Defaults.Add(new ExtJS.Parameter { Name = "width", Value = "80", Mode = ParameterMode.Raw });
    grid.ColumnModel.Columns.AddRange(cols);
    grid.SelectionModel.Add(new RowSelectionModel() { SingleSelect = true });
    grid.LoadMask.Msg = "Loading...";
    grid.LoadMask.ShowMask = true;
    grid.BottomBar.Add(new PagingToolbar { PageSize = 25 });
    grid.Plugins.Add(GetGridFilters(rectype));
    grid.GetStore().BaseParams.Add(new ExtJS.Parameter { Name = "filter", Value = "#{" + grid.ID + "}.getFilterPlugin().buildQuery(#{"+grid.ID+"}.get FilterPlugin().getFilterData())", Mode = ParameterMode.Raw, Encode=true });
    return grid;
    }

    Thanks,

Similar Threads

  1. GridFilters plugin not displaying
    By Skizzot223 in forum 1.x Help
    Replies: 1
    Last Post: Apr 11, 2012, 12:49 PM
  2. Remote GridFilters via HttpProxy
    By Thinjon100 in forum 1.x Help
    Replies: 1
    Last Post: Sep 19, 2011, 1:39 PM
  3. [CLOSED] GridFilters Plugin and MVC
    By Stefanaccio in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: Jan 06, 2011, 3:23 PM
  4. [CLOSED] GridFilters plugin with HttpProxy
    By tdracz in forum 1.x Legacy Premium Help
    Replies: 13
    Last Post: Oct 07, 2009, 7:25 AM
  5. [CLOSED] AjaxEvent add filter to GridFilters plugin
    By methode in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 09, 2009, 12:14 PM

Tags for this Thread

Posting Permissions