Jul 06, 2016, 1:45 AM
Combo select handler not fire when only one result
Please try the sample, try these steps to reproduce:
1. type prod and press button, then select any result, you will see two msg notified.
2. type 100 and press button, then select the only one result, you won't see any msg.
1. type prod and press button, then select any result, you will see two msg notified.
2. type 100 and press button, then select the only one result, you won't see any msg.
<%@ Page Language="C#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.Net" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
}
}
[DirectMethod(ShowMask = true)]
public void SearchWorkItem()
{
string strSearch = this.SearchBox.Text;
int n;
if ( int.TryParse(strSearch, out n) )
{
SearchStore.DataSource = new object[]
{
new object[] { "100", "Prod1", "Alabama", "The Heart of Dixie" }
};
}
else
{
SearchStore.DataSource = new object[]
{
new object[] { "100", "Prod1", "Alabama", "The Heart of Dixie" },
new object[] { "101", "Prod2", "Alaska", "The Land of the Midnight Sun" },
new object[] { "102", "Prod3", "Arizona", "The Grand Canyon State" }
};
}
SearchStore.DataBind();
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=100" />
<script>
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" DirectMethodNamespace="MyCompany" >
</ext:ResourceManager>
<ext:Panel
runat="server"
Border="false"
Layout="Form"
ColumnWidth="0.3"
LabelAlign="Top"
>
<Defaults>
<ext:Parameter Name="MsgTarget" Value="side" />
</Defaults>
<Items>
<ext:ComboBox
ID="SearchBox"
runat="server"
Width="500"
DisplayField="Title"
ValueField="ID"
FieldLabel="Serch WorkItem"
AllowBlank="true"
AutoLoad="false"
PageSize="10"
EmptyText="Input text and press button to search"
QueryDelay="100000"
>
<Store>
<ext:Store ID="SearchStore" runat="server" IsPagingStore="true" PageSize="10" >
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="ID" />
<ext:ModelField Name="Info" />
<ext:ModelField Name="AssignedTo" />
<ext:ModelField Name="Title" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ListConfig Width="600" Height="300" ItemSelector=".x-boundlist-item">
<Tpl runat="server">
<Html>
<tpl for=".">
<tpl if="[xindex] == 1">
<table class="cbStates-list">
<tr>
<th>ID</th>
<th>WorkItem</th>
<th>AssignedTo</th>
<th>Title</th>
</tr>
</tpl>
<tr class="x-boundlist-item">
<td>{ID}</td>
<td>{Info}</td>
<td>{AssignedTo}</td>
<td>{Title}</td>
</tr>
<tpl if="[xcount-xindex]==0">
</table>
</tpl>
</tpl>
</html> </Tpl>
</ListConfig>
<Triggers>
<ext:FieldTrigger Icon="Clear" Hidden="true" />
</Triggers>
<Listeners>
<BeforeQuery Handler="this.getTrigger(0)[this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
<TriggerClick Handler="if (index == 0) {
this.focus().clearValue();
trigger.hide();
}" />
<Select Handler="this.getTrigger(0).show();
Ext.Msg.notify('',#{SearchBox}.getValue());
Ext.Msg.notify('',#{SearchBox}.getRawValue());
" />
</Listeners>
<RightButtons>
<ext:Button ID="ButtonSearch" runat="server" Icon="Zoom" Handler="function () {#{DirectMethods}.SearchWorkItem();#{SearchBox}.onTriggerClick();}" />
</RightButtons>
</ext:ComboBox >
</Items>
</ext:Panel>
</form>
</body>
</html>
Last edited by rickywu; Jul 06, 2016 at 1:51 AM.