EXT.NET(八)Combox 实现模糊异步查询

突然间想到百度和GOOGLE的AJAX模糊查询的功能。那就COMBOX中能不能实现呢?

查看资料

在数据源中多了一个

<Proxy>
<ext:HttpProxy Method="POST" Url="Plants.ashx" />
</Proxy>

估计是异步的东东。本人才浅

先建立一个

<%@ WebHandler Language="C#" Class="DataHandler" %>

using System;
using System.Web;
using System.Collections.Generic;
using Ext.Net;
using System.Data;

public class DataHandler : IHttpHandler {
public void ProcessRequest(HttpContext context)
{
if (!string.IsNullOrEmpty(context.Request["query"]))
{

string query = context.Request["query"];

context.Response.ContentType = "text/json";

DataTable table = new DAL.UserDAO().WorkNoList(query).Tables[0] ;

List<UserInfo> lst = new List<UserInfo>();

foreach (DataRow row in table.Rows)
{

UserInfo user = new UserInfo();

user.UserName = Convert.ToString(row["name"]);
//user.UserId = Convert.ToInt32(row["workno"]);
user.UserId = Convert.ToString(row["workno"]);
lst.Add(user);

}

string json = Ext.Net.JSON.Serialize(lst);

context.Response.Write(json);

}

else
{

context.Response.ContentType = "text/json";

DataTable table = new DAL.UserDAO().WorkNoList().Tables[0] ;

List<UserInfo> lst = new List<UserInfo>();

foreach (DataRow row in table.Rows)
{

UserInfo user = new UserInfo();

user.UserName = Convert.ToString(row["name"]);
//user.UserId = Convert.ToInt32(row["workno"]);
user.UserId = Convert.ToString(row["workno"]);
lst.Add(user);

}

string json = Ext.Net.JSON.Serialize(lst);

context.Response.Write(json);


}

}

public bool IsReusable
{
get
{
return false;
}
}
}

public class UserInfo
{
private string _UserName;

public string UserName
{
get { return _UserName; }
set { _UserName = value; }
}
private string _UserId;

public string UserId
{
get { return _UserId; }
set { _UserId = value; }
}


}

看看效果吧

EXT.NET(八)Combox 实现模糊异步查询

你可能感兴趣的:(combox)