Oct 13, 2011, 8:30 PM
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:
Thank you.
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.