1, 引入dll : ResourceResourceMediinfo.AjaxControls.dll
2, 加载样式:
3, 加载 js
4, 设置页面控件 引入ScriptManager
CtrlTextID=" hfldZHUANGWANGJGMC" CtrlValuID="hfldZHUANGWANGJG"
隐藏绑定值:机构名称及机构编号 ,便于交互
AjaxPath="/Web References/AutoCompDataSource.asmx" ajax 路径
AjaxMethod="GetAgencyByFix" ajax 执行方法
范例:
AllowUnresolvedItems=”true” CtrlTextID=”hfldHUJIDZMC” CtrlValuID=”hfldHUJIDZBH”
AllowMulti=”false” IsGanged=”JiaTing,XiuYang,ZFHuJi” HasDesc=”true” DescCtrl=”HuJi_Desc”
ExpandWidth=”300″ AllowedMaxItems=”1″ RootCSSClass=”suggester” ItemCSSClass=”ui-corner-all”
AjaxPath=”/Web References/AutoCompDataSource.asmx” AjaxMethod=”GetItemsByFix”
ScriptPath=”/Scripts/Suggester.js?t=20131017″ OnClientBeginRequest=”Address.BeginRequest”
OnClientItemAdded=”Address.ItemAdd_HuJi” OnClientItemRemoved=”Address.ItemRemovedGrad” />
选择控件中的下拉项给隐藏域中的控件赋值选中项的ID和value;
使用控件判断隐藏域中的值是否符合规则即可.
if ($.trim($("#hfldHUJIDZBH").val()) == '' || $.trim($("#hfldHUJIDZBH").val()) == '990000000000') {
top.$.messager.alert('提示信息', '请输入关键字检索选择户籍地址(请从检索目中选择)!', 'info', function () { ExpandFun.setCtrlFocus("HuJi"); });
return false;
}
聚焦定位到控件(具体参考项目中form.js 中的定义)
ExpandFun.setCtrlFocus("HuJi");
允许用户填写字典中不存在的项目
设置属性
AllowUnresolvedItems="true"
范例
AjaxOnTextLength="0" AllowMulti="true" CtrlTextID="hfldSITAISCYY" CtrlValuID="hfldSITAISCYYDM"
DicNumStr="4|183" RootCSSClass="suggester" AllowedMaxItems="20" ExpandHeight="200"
AllowUnresolvedItems="true" ItemCSSClass="ui-corner-all" AjaxPath="/Web References/AutoCompDataSource.asmx"
AjaxMethod="GetDictByFixAndDicNum" ScriptPath="/Scripts/Suggester.js" OnClientBeginRequest="ajax_AutoFinish.onBeginRequest_Dic"
OnClientItemAdded="onItemAdded_DisQTSTCtrl" OnClientItemRemoved="onItemRemoved_DisQTSTCtrl" />
如果 AllowUnresolvedItems=”false” 则用户自行输入字典中不存在的项目;保存时无法给CtrlTextID=”hfldSITAISCYY” CtrlValuID=”hfldSITAISCYYDM” 这俩项赋值
只有AllowUnresolvedItems=”true”时,输入字段中不存在的项目也会给CtrlTextID=”hfldSITAISCYY” 赋值为用户实际输入项CtrlValuID=”hfldSITAISCYYDM” 会赋值-99
控件传递参数范例
Watermark="输入字典汉字全称(拼音码缩写)" AjaxOnTextLength="0" AllowMulti="true" CtrlTextID="hfldZHONGXYFWNR"
CtrlValuID="hfldZHONGXYFWNRDM" DicNumStr="9|816" RootCSSClass="suggester" AllowedMaxItems="5"
ItemCSSClass="ui-corner-all" Height="20" AjaxPath="/Web References/AutoCompDataSource.asmx"
AjaxMethod="GetDicByExpress" ViewType="1,2,3,4,5,9" ScriptPath="/Scripts/Suggester.js"
OnClientBeginRequest="ajax_AutoFinish.onBeginRequest_Dic" OnClientItemAdded="ajax_AutoFinish.onItemAdded_Dic"
OnClientItemRemoved="ajax_AutoFinish.onItemRemoved_Dic" />
其中
AjaxPath="/Web References/AutoCompDataSource.asmx" //项目路径
AjaxMethod="GetDicByExpress" //调用的方法
ViewType="1,2,3,4,5,9" //传递的参数
源码参考
[WebMethod(Description = "字典选择[根据表达式]")]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public ListGetDicByExpress(Request request)
{
if (!string.IsNullOrEmpty(request.DicSysNum) && !string.IsNullOrEmpty(request.DicItemNum) && !string.IsNullOrEmpty(request.ViewType))
{
var result = new List();
string PYM = request.Prefix.ToUpper();
string strSql = "(PINGYINM LIKE'%{0}%' OR DAIMAMC LIKE'%{0}%') AND xiangmubh={1} and xitongbh={2} AND ZHUXIAOBZ=2 AND DAIMA IN({3}) AND ROWNUM var query = string.Format(strSql, PYM, request.DicItemNum, request.DicSysNum, request.ViewType);
var list = new BLL.VGY_ZD_XIANGMUZD().GetEntityList(query, "SHUNXUH");
foreach (var item in list)
{
var items = new Complete.Item { Id = item.DAIMA, Text = item.DAIMAMC };
result.Add(items);
}
return result;
}
else
{
return null;
}
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.e1idc.net