前台页面 aspx:
数据源:
<ext:Store ID="storeJF" runat="server" AutoLoad="true">
<Proxy>
<ext:HttpProxy Method="POST" Url="Sel/SelJF.ashx?type=1" />
</Proxy>
<Reader>
<ext:JsonReader Root="root">
<Fields>
<ext:RecordField Name="Conid" />
<ext:RecordField Name="Firstpart" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
这里注意: 需要一个一般处理程序
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class SelJF : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string type = "";
if (context.Request.QueryString.AllKeys.Contains("type"))
{
type = context.Request.QueryString["type"] as string;
}
var dept = string.Empty;
var query = string.Empty;
if (!string.IsNullOrEmpty(context.Request["query"]))
{
query = context.Request["query"];
}
string Condition = "";
switch (type)
{
case "1":
Condition = " Deleteflg = 'F'";
break;
default:
Condition = "";
break;
}
if (query != "")
{
Condition += " AND Firstpart LIKE '%" + query + "%'";
}
string root = "";
DataSet ds = BizCommon.SelectInfo("JL_Contract", Condition, "Firstpart", new string[] { "DISTINCT TOP(10) Firstpart" });
if (ds != null && ds.Tables.Count > 0)
{
root = Inchsoft.Common.StringHelper.GetJsonString(ds.Tables[0]);
}
context.Response.Write(string.Format("{{'root':{0}}}", root));
}
public bool IsReusable
{
get
{
return false;
}
}
主体控件:
<ext:ComboBox ID="cmbfirstpart" runat="server" FieldLabel="甲方" DataIndex="Firstpart"
LabelStyle="text-align:right;" Editable="true" HideTrigger="true" StoreID="StoreJF"
DisplayField="Firstpart" ValueField="Firstpart" ForceSelection="false" LoadingText="查找中..."
ItemSelector="div.search-item" MinChars="1" typeAhead="true">
<Template ID="tpl" runat="server">
<tpl for=".">
<div class="search-item">{Firstpart}</div>
</tpl>
</Template>
</ext:ComboBox>
后台自由取值:
model.Firstpart = cmbfirstpart.SelectedItem.Text.Trim();