Nov 15, 2014, 3:46 PM
[CLOSED] ListFilter Update items
Below is an example of a ListFilter populated via a store. There are two buttons that will attempt to reload the store with 3 items (full) or 2 items (partial). After reloading the store how do I tell the filter to refresh?
Follow these steps:
Follow these steps:
- Launch example
- Look at the ListFilter for Category, it should have 2 items.
- Press the "Update (Full)" button
- Look at the ListFilter again , it might have 3 items but most likely it still shows 2.
- Drag the Category column to the first column.
- Look at the ListFilter again and it will have 3 items.
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>
<html>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.GridStore.DataSource = new object[]
{
new object[] { 1, "Baseline", "Training Guide"},
new object[] { 2, "Reference", "How to ..."},
new object[] { 3, "Archive", "Training Guide (1983)"},
};
this.GridStore.DataBind();
BuildCategoryStore(false);
}
}
protected void UpdateFull(object sender, DirectEventArgs e)
{
BuildCategoryStore(true);
}
protected void UpdatePartial(object sender, DirectEventArgs e)
{
BuildCategoryStore(false);
}
private void BuildCategoryStore(Boolean full)
{
List<object> data = new List<object>
{
new { Cat = "Baseline", IsActive = true, CatCombined = "Baseline" },
new { Cat = "Reference", IsActive = true, CatCombined = "Reference" },
};
if (full)
{
object storeData = new { Cat = "Archive", IsActive = false, CatCombined = "Archive <font color=red><i>(Inactive)</i></font>" };
data.Add(storeData);
}
this.CategoryStore.DataSource = data;
this.CategoryStore.DataBind();
}
</script>
<head runat="server">
<title>ListFiler Example</title>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:GridPanel runat="server">
<Bin>
<ext:Store ID="CategoryStore" runat="server">
<Model>
<ext:Model runat="server" IDProperty="Cat">
<Fields>
<ext:ModelField Name="id" Mapping="Cat" Type="String" />
<ext:ModelField Name="IsActive" Type="Boolean" />
<ext:ModelField Name="CatCombined" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Bin>
<Store>
<ext:Store ID="GridStore" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="Id" />
<ext:ModelField Name="Category" Type="String" />
<ext:ModelField Name="Title" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Id" DataIndex="Id" Width="50" />
<ext:Column runat="server" Text="Category" DataIndex="Category" Width="120" />
<ext:Column runat="server" Text="Title" DataIndex="Title" Flex="1" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" Mode="Single" />
</SelectionModel>
<Features>
<ext:GridFilters ID="GridFilters" runat="server" Local="true">
<Filters>
<ext:ListFilter DataIndex="Category" StoreID="CategoryStore" LabelField="CatCombined"
IDField="id" />
</Filters>
</ext:GridFilters>
</Features>
</ext:GridPanel>
<ext:Button runat="server" Text="Update (Full)" OnDirectClick="UpdateFull" />
<ext:Button runat="server" Text="Update (Partial)" OnDirectClick="UpdatePartial" />
</body>
</html>
Last edited by Daniil; Nov 17, 2014 at 1:35 PM.
Reason: [CLOSED]