Ext.js Combobox 输入模糊匹配

博客展示了前台页面aspx的相关代码,包含数据源的配置,如使用ext:Store获取数据,还需一般处理程序SelJF处理请求。同时给出主体控件ext:ComboBox的代码,以及后台自由取值的方式,最后标注了转载来源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

前台页面 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();

 

转载于:https://www.cnblogs.com/wusirAaron/p/9544985.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值