easyUI-combobox 动态绑定数据源
前台
<link rel="stylesheet" type="text/css" href="../css/easyui.css"/>
<script type="text/JavaScript" src="../js/jQuery-1.7.1.min.js"></script>
<script type="text/javascript" src="../js/jquery.easyui.min.js"></script>
<script type="text/javascript">
var vID = "DDLCC";
$(function () {
$('#' + vID).combobox({
valueField: 'TPrice', //TPrice
textField: 'typeName',
//注册事件
onChange: function (newValue, oldValue) {
if (newValue != null) {
var thisKey = encodeURIComponent($('#' + vID).combobox('getValue')); //搜索词
var thisType = ""; //车辆类型
var urlStr = "AutoComplete.ashx?objType=" + thisType + "&objStr=" + thisKey;
$("#" + vID).combobox("reload", urlStr);
}
},
onSelect: function (record) {
setValue(record.typeName);
//document.getElementById("TextBox4").value = record.TPrice;
$("#TextBox4").val(record.TPrice);
}
});
});
function setValue(vTxt) {
$('#' + vID).combobox('setValue', vTxt);
}
</script>
<style type="text/css">
.combo
{
height:15px;
border:1px solid #CECCCD;
overflow :hidden ;
}
.combo .combo-text{
height:15px;
font-size:12px;
line-height:15px;
color :#000000;
}
.combo .combo-arrow{
background:#E0ECF9 url('../css/images/combo_arrow.gif') no-repeat 0px 0px;
width:14px;
height:15px;
overflow:hidden;
vertical-align:middle;
cursor:pointer;
opacity:0.6;
filter:alpha(opacity=60);
}
</style>
<select id="DDLCC" class="easyui-combobox" name="DDLCC" style="width:84px;" data-options="required:true" title="键入搜索查询" >
</select>
后台
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using Newtonsoft.Json;
using System.Text;
namespace used_car.web
{
/// <summary>
/// AutoComplete 的摘要说明
/// </summary>
public class AutoComplete : IHttpHandler
{
protected DataTable dt = null;
public void ProcessRequest(HttpContext context)
{
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
ClearClientPageCache();
context.Response.ContentType = "text/plain";
string strObjTypee = "", strObjStr = "";
if (context.Request.QueryString["objType"] != null && context.Request.QueryString["objStr"]!=null)
{
strObjTypee = context.Server.UrlDecode(context.Request.QueryString["objType"].ToString());
strObjStr = context.Server.UrlDecode(context.Request.QueryString["objStr"].ToString());
dt = linkeMaterials(strObjTypee, strObjStr);
if (dt != null)
{
string data2 = JsonConvert.SerializeObject(dt);
context.Response.Write(data2);
context.Response.Flush();
context.Response.End();
}
}
}
public DataTable linkeMaterials(object objType, object objStr)
{
DataTable dt = new DataTable();
if (objStr != null)
{
if (!string.IsNullOrWhiteSpace(objStr.ToString()))
{
//left(T11,2)='" + objType + "' or
string strSql = "select top 15 C.T46 as typeName, C.T45 as ID,C.T47 as TPrice from [dbo].[JC79] as C where T46 like'%" + objStr + "%'";
DataSet dsJC97 = Maticsoft.DBUtility.DbHelperSQL.Query(strSql);
dt = dsJC97.Tables[0];
}
}
return dt;
}
StringBuilder sbJC97 = new StringBuilder("");
public string linkeMaterials2(object objType, object objStr)
{
if (objStr != null)
{
if (!string.IsNullOrWhiteSpace(objStr.ToString()))
{
//left(T11,2)='" + objType + "' or
string strSql = "select top 15 C.T46 as 型号名称, C.T47 as 现行价格, C.T45 as ID,C.T11 as 种类编号 from [dbo].[JC79] as C where T46 like'%" + objStr + "%'";
DataSet dsJC97 = Maticsoft.DBUtility.DbHelperSQL.Query(strSql);
if (dsJC97 != null)
{
DataTable dtJC97 = dsJC97.Tables[0];
int dtCount = dtJC97.Rows.Count;
if (dtCount > 0)
{
for (int i = 0; i < dtCount; i++)
{
sbJC97.Append("{ typeName: \"" + dtJC97.Rows[i]["型号名称"] + "\",ID: \"" + dtJC97.Rows[i]["ID"] + "\",Price: \"" + dtJC97.Rows[i]["现行价格"] + "\",ZL: \"" + dtJC97.Rows[i]["种类编号"] + "\"}");
if (i != (dtCount - 1))//如果不是最后一个
{
sbJC97.Append(",");
}
}
}
}
}
}
return sbJC97.ToString();
}
public bool IsReusable
{
get
{
return false;
}
}
public static void ClearClientPageCache()
{
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Expires = 0;
HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
HttpContext.Current.Response.AddHeader("pragma", "no-cache"); HttpContext.Current.Response.AddHeader("cache-control", "private"); HttpContext.Current.Response.CacheControl = "no-cache";
}
}
}
easyUI-combobox 动态绑定数据源的更多相关文章
- easyui combobox点击输入框弹出下拉框
由于easyui combobox需要点击下拉箭头才能下拉,不能像select标签那样点击输入框就下拉,所以觉得不太方便,查看了一下,combobox弹出框是一个div,原本想在他的输入框的点击事件中 ...
- jQuery easyui combobox获取值|easyui-combobox获取多个值
Query easyui combobox事例: name="language" data-options=" ...
- easyui combobox onSelect事件
easyui combobox 没有onchange事件,只有onSelect事件 1 $(function () { $('#Select6').combobox({ onSelect: funct ...
- jquery easyui combobox 级联及触发事件,combobox级联
jquery easyui combobox 级联及触发事件,combobox级联 >>>>>>>>>>>>>>&g ...
- Easyui combobox onChange事件
Easyui combobox onChange事件: 注册事件: $(function () { $('#cc_id').combobox({ onChange: function (newValu ...
- JQuery EasyUI Combobox的onChange事件
html中的select 的change事件 <select id="consult_province" name="consult_province" ...
- 关于easyui combobox下拉框实现多选框的实现
好长时间没有更博了,一是因为最近真的比较忙,二是因为自己是真的偷懒了,哈哈 好啦,这篇博客主要是总结一些关于easyui combobox下拉框实现多选框的实现,包括前台界面的展示,和后台对数据的获取 ...
- easyui combobox下拉框复制后再禁用,点击不会出现下拉框
easyui combobox下拉框禁用,点击不会出现下拉框 需要做到,在给easyui combobox赋值后,再禁用easyui combobox 解决办法: $("#time-sele ...
- easyui combobox开启搜索自动完成功能
combo.json [{ "id":-1, "text":" ", "spell":"" },{ ...
- 表单(上)EasyUI Form 表单、EasyUI Validatebox 验证框、EasyUI Combobox 组合框、EasyUI Combo 组合、EasyUI Combotree 组合树
EasyUI Form 表单 通过 $.fn.form.defaults 重写默认的 defaults. 表单(form)提供多种方法来执行带有表单字段的动作,比如 ajax 提交.加载.清除,等等. ...
随机推荐
- mongoperf
官方文档 mongoperf is a utility to check disk I/O performance independently of MongoDB. It times tests o ...
- 基于Python的TestAgent实现
问题: 1.本人工作主要做自动化,经常要去Linux后台进行一些脚本操作,有时要去后台执行命令,如果逐个登陆比较费事,效率会大打折扣 2.虽然有可以直接去后台执行命令的AW,但是该AW存在很多问题,而 ...
- Renci.SshNet在Linux运维的应用
SSH.NET是一个.net的SSH应用库,支持并发.该库最新的代码可以从github上下载下来,比Sharp.SSH更新的频繁.它可以模拟ssh登陆,类似xshell.putty等工具.不过有更多的 ...
- 设置glassfish开启自动domain
1-在/etc/rc.local中配置开机自启动 su - sumapay25 -c "/opt/glassfish.sh start 1" 2-/opt/glassfish.sh ...
- Reflection应用场景-利用反射机制将表单数据自动填充到JavaBean中
- Django 中url补充以及模板继承
Django中的URL补充 默认值 在url写路由关系的时候可以传递默认参数,如下: url(r'^index/', views.index,{"name":"root& ...
- 在CentOS下自动备份mysql
在CentOS下自动备份mysql数据库,并差异同步到其它网络主机上 1.在/root/mysql_backup/下添加backup.sh:vim /root/mysql_backup/backup. ...
- lua自定义迭代器
迭代器 http://www.tutorialspoint.com/lua/lua_iterators.htm 迭代器能够让你遍历某个集合或者容器中的每一个元素. 对于lua来说, 集合通常指代 ta ...
- 在Ubuntu 12.04下采用apt-get的方法安装Qt4
在Ubuntu 12.04下采用apt-get的方法安装Qt4 注:之前发表的一篇博客是采用编译源码的方式安装Qt4,这是很有用的方式,因为源码安装对于所有系统都是通用的,其次,在使用交叉编译器的时候 ...
- 3.MongoDB下Windows下的安装
由于博主目前使用的是Windows的系统,没有使用Linux等其它的系统,因此此安装配置和开发使用,均是在Windows下进行的,以后在使用其它的系统的时候,再将其它系统的配置的使用补充上来. 1.下 ...