Jan 31, 2013, 2:58 PM
ComboBox Local Mode Filter Issue(Urgent)
I have two combobox column in GridPanel (Country and State). I have filtered state client side only in beforeedit of gridpanel.
Now when I type something (e.g abcd which is not in state) in state Combo and then clear the typed character without going out to edit mode of state combo, then it gives me all list of state even I filtered state in beforeedit listener of particular country.
Screen also attached.
I want filtered record only which is done in beforeedit even when I clears selection in state combo.
Following is runnable simple sample.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
List<object> data = new List<object>
{
new {Country = "C1", State = "C1_S1"},
new {Country = "C2", State = "C2_S1"},
new {Country = "C3", State = "C3_S1"},
};
Store1.DataSource = data;
Store1.DataBind();
List<object> countries = new List<object>
{
new {Country = "C1"},
new {Country = "C2"},
new {Country = "C3"},
};
CountryStore.DataSource = countries;
CountryStore.DataBind();
List<object> states = new List<object>
{
new {Country = "C1", State="C1_S1"},
new {Country = "C1", State="C1_S2"},
new {Country = "C1", State="C1_S3"},
new {Country = "C1", State="C1_S4"},
new {Country = "C1", State="C1_S5"},
new {Country = "C2", State="C2_S1"},
new {Country = "C2", State="C2_S2"},
new {Country = "C2", State="C2_S3"},
new {Country = "C2", State="C2_S4"},
new {Country = "C2", State="C2_S5"},
new {Country = "C3", State="C3_S1"},
new {Country = "C3", State="C3_S2"},
new {Country = "C3", State="C3_S3"},
new {Country = "C3", State="C3_S4"},
new {Country = "C3", State="C3_S5"},
};
StateStore.DataSource = states;
StateStore.DataBind();
}
}
</script>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>Ext.NET Examples</title>
<link href="/resources/css/examples.css" rel="stylesheet" />
<script>
var beforedit = function (editor, e) {
if (e.field == 'state') {
App.StateStore.clearFilter();
App.StateStore.filter('Country', App.Store1.data.items[e.rowIdx].data.country);
}
};
</script>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Store ID="CountryStore" runat="server" IDMode="Static">
<Model>
<ext:Model ID="Model1" runat="server" IDProperty="Country">
<Fields>
<ext:ModelField Name="Country" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
<ext:Store ID="StateStore" runat="server" IDMode="Static" >
<Model>
<ext:Model ID="Model2" runat="server" IDProperty="State">
<Fields>
<ext:ModelField Name="Country" Type="String" />
<ext:ModelField Name="State" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
<ext:GridPanel
ID="GridPanel1"
runat="server"
Height="300"
Width="600"
Title="Grid"
ForceFit="true"
IDMode="Static">
<Store>
<ext:Store ID="Store1" runat="server" >
<Model>
<ext:Model ID="Model5" runat="server">
<Fields>
<ext:ModelField Name="country" Type="String" Mapping="Country" />
<ext:ModelField Name="state" Type="String" Mapping="State" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column ID="Column1" runat="server" DataIndex="country" Text="Country">
<Editor>
<ext:ComboBox
ID="CountryCombo"
runat="server"
QueryMode="Local"
TriggerAction="All"
StoreID="CountryStore"
ValueField="Country"
DisplayField="Country">
</ext:ComboBox>
</Editor>
</ext:Column>
<ext:Column ID="Column2" runat="server" DataIndex="state" Text="State">
<Editor>
<ext:ComboBox
ID="StateCombo"
runat="server"
QueryMode="Local"
StoreID="StateStore"
ValueField="State"
DisplayField="State">
</ext:ComboBox>
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
<Plugins>
<ext:CellEditing>
<Listeners>
<BeforeEdit Fn="beforedit"></BeforeEdit>
</Listeners>
</ext:CellEditing>
</Plugins>
</ext:GridPanel>
</form>
</body>
</html>
Now when I type something (e.g abcd which is not in state) in state Combo and then clear the typed character without going out to edit mode of state combo, then it gives me all list of state even I filtered state in beforeedit listener of particular country.
Screen also attached.
I want filtered record only which is done in beforeedit even when I clears selection in state combo.
Following is runnable simple sample.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
List<object> data = new List<object>
{
new {Country = "C1", State = "C1_S1"},
new {Country = "C2", State = "C2_S1"},
new {Country = "C3", State = "C3_S1"},
};
Store1.DataSource = data;
Store1.DataBind();
List<object> countries = new List<object>
{
new {Country = "C1"},
new {Country = "C2"},
new {Country = "C3"},
};
CountryStore.DataSource = countries;
CountryStore.DataBind();
List<object> states = new List<object>
{
new {Country = "C1", State="C1_S1"},
new {Country = "C1", State="C1_S2"},
new {Country = "C1", State="C1_S3"},
new {Country = "C1", State="C1_S4"},
new {Country = "C1", State="C1_S5"},
new {Country = "C2", State="C2_S1"},
new {Country = "C2", State="C2_S2"},
new {Country = "C2", State="C2_S3"},
new {Country = "C2", State="C2_S4"},
new {Country = "C2", State="C2_S5"},
new {Country = "C3", State="C3_S1"},
new {Country = "C3", State="C3_S2"},
new {Country = "C3", State="C3_S3"},
new {Country = "C3", State="C3_S4"},
new {Country = "C3", State="C3_S5"},
};
StateStore.DataSource = states;
StateStore.DataBind();
}
}
</script>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>Ext.NET Examples</title>
<link href="/resources/css/examples.css" rel="stylesheet" />
<script>
var beforedit = function (editor, e) {
if (e.field == 'state') {
App.StateStore.clearFilter();
App.StateStore.filter('Country', App.Store1.data.items[e.rowIdx].data.country);
}
};
</script>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Store ID="CountryStore" runat="server" IDMode="Static">
<Model>
<ext:Model ID="Model1" runat="server" IDProperty="Country">
<Fields>
<ext:ModelField Name="Country" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
<ext:Store ID="StateStore" runat="server" IDMode="Static" >
<Model>
<ext:Model ID="Model2" runat="server" IDProperty="State">
<Fields>
<ext:ModelField Name="Country" Type="String" />
<ext:ModelField Name="State" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
<ext:GridPanel
ID="GridPanel1"
runat="server"
Height="300"
Width="600"
Title="Grid"
ForceFit="true"
IDMode="Static">
<Store>
<ext:Store ID="Store1" runat="server" >
<Model>
<ext:Model ID="Model5" runat="server">
<Fields>
<ext:ModelField Name="country" Type="String" Mapping="Country" />
<ext:ModelField Name="state" Type="String" Mapping="State" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column ID="Column1" runat="server" DataIndex="country" Text="Country">
<Editor>
<ext:ComboBox
ID="CountryCombo"
runat="server"
QueryMode="Local"
TriggerAction="All"
StoreID="CountryStore"
ValueField="Country"
DisplayField="Country">
</ext:ComboBox>
</Editor>
</ext:Column>
<ext:Column ID="Column2" runat="server" DataIndex="state" Text="State">
<Editor>
<ext:ComboBox
ID="StateCombo"
runat="server"
QueryMode="Local"
StoreID="StateStore"
ValueField="State"
DisplayField="State">
</ext:ComboBox>
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
<Plugins>
<ext:CellEditing>
<Listeners>
<BeforeEdit Fn="beforedit"></BeforeEdit>
</Listeners>
</ext:CellEditing>
</Plugins>
</ext:GridPanel>
</form>
</body>
</html>