PDA

View Full Version : ListFilter_Remote with Mapping



howardyin
Apr 28, 2012, 5:03 AM
I read this tread:http://forums.ext.net/showthread.php?11414-ListFilter-with-mappings,and tried to using "StoreID" of ListFilter,but the filters menu is always "Loading ...".
What's wrong with it? Or is there an example of ListFilter using StoreID? Thanks.


<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.Store2.DataSource = this.Data2;
this.Store2.DataBind();
}
}

protected void Store_OnRefreshData(object sender, StoreRefreshDataEventArgs e)
{
object[] data = Data;

string rawFilter = e.Parameters["filter"];
if (!string.IsNullOrEmpty(rawFilter))
{
//data filter
}

this.GridPanel1.GetStore().DataSource = data;
this.GridPanel1.GetStore().DataBind();
}

private object[] Data
{
get
{
return new object[]
{
new { company = "3m Co",type = "1"},
new { company = "Alcoa Inc", type = "2"},
new { company = "Altria Group Inc", type = "2"},
new { company = "American Express Company", type = "3"},
new { company = "American International Group, Inc.", type = "3"}
};
}
}

private object[] Data2
{
get
{
return new object[]
{
new { value = "1", label = "a"},
new { value = "2", label = "b"},
new { value = "3", label = "c"},
new { value = "4", label = "d"},
new { value = "5", label = "e"}
};
}
}
</script>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Store ID="Store2" runat="server">
<Model>
<ext:Model ID="Model2" runat="server" IDProperty="value">
<Fields>
<ext:ModelField Name="value" />
<ext:ModelField Name="label" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
<ext:GridPanel ID="GridPanel1" runat="server">
<Store>
<ext:Store ID="Store1" runat="server" OnReadData="Store_OnRefreshData">
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="company" />
<ext:ModelField Name="type" />
</Fields>
</ext:Model>
</Model>
<Proxy>
<ext:PageProxy />
</Proxy>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column ID="Column1" runat="server" Text="Company" DataIndex="company" />
<ext:Column ID="Column2" runat="server" Text="Type" DataIndex="type">
<Renderer Handler="function(v){return {1:'a',2:'b',3:'c','4':'d',5:'e'}[v];}" />
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
</SelectionModel>
<Features>
<ext:GridFilters>
<Filters>
<ext:ListFilter DataIndex="type" LabelField="label" StoreID="Store2" />
<%-- <ext:ListFilter DataIndex="type" Options="a,b,c,d,e" />--%>
</Filters>
</ext:GridFilters>
</Features>
</ext:GridPanel>
</form>
</body>
</html>