|
本帖最后由 Vincent 于 2012-4-18 10:15 编辑
if (!IsPostBack)
{
ExtAspNet.PageContext.RegisterStartupScript(
"var d=Ext.getCmp('" + ddlOrderCode.ClientID + "');" +
" d.listWidth=150; " +
" d.addListener(\"keyup\",function(f,e){ " +
" var arr=['8','16','17','37','38','39','40','13']; " +
" var x=e.keyCode; " +
" for(var n=0 ;n<arr.length;n++) {if (parseInt(arr[n])==parseInt(x)) {return;} }" +
" __doPostBack('loaddata',document.getElementById(\"" + ddlOrderCode.ClientID + "\").value);" +
"});"
);
}
else
{
if (Request["__EVENTTARGET"] == "loaddata")
{
string input = Request["__EVENTARGUMENT"];
ddlOrderCode.Items.Clear();
List<his.Model.D_DICT> list = d_dict.GetList(input);
foreach (his.Model.D_DICT m in list)
{
ddlOrderCode.Items.Add(new ExtAspNet.ListItem(m.DRUG_NAME.Trim()+"_"+m.DRUG_CODE.Trim(), m.DRUG_CODE.Trim()));
}
string strTimeMark = DateTime.Now.Ticks.ToString();
ddlOrderCode.Items.Add(new ExtAspNet.ListItem("请输入拼音码或文字进行查找选择", strTimeMark));
ddlOrderCode.SelectedValue = strTimeMark;
ddlOrderCode.SelectedItem.EnableSelect = false;
ExtAspNet.PageContext.RegisterStartupScript("document.getElementById(\"" + ddlOrderCode.ClientID + "\").value=newInput;");
}
}
}
protected override void Render(HtmlTextWriter writer)
{
StringWriter strWriter = new StringWriter();
base.Render(new HtmlTextWriter(strWriter));
writer.Write(
strWriter.ToString().Replace("id:\"" + ddlOrderCode.ClientID + "\",", "id:\"" + ddlOrderCode.ClientID + "\",editable: true,hideTrigger:true,")
);
}
如图前台实现的效果,如果我用Enter键选择的话,ddl里是有值的,但是点击获取规格没有效果,因为ddl的selectValue根本就没有值,想请教一下,如何才能让enter有用!!!!!
红色部分是改动部分!!!我想这样的功能会很有用的!所以来分享一下!,还有个问题想请教一下大家,就是下拉框中下拉出来的是药名和药品的代码,我想问一下选择之后只让药品在文本框中显示不知有人会做否?或者给个提示也行!!!
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|