《select下拉可编辑》由会员分享,可在线阅读,更多相关《select下拉可编辑(5页珍藏版)》请在金锄头文库上搜索。
1、基于 jQuery 的1 2 用 LoadComboBoxAADept方法绑定LoadComboBoxAADept(Dept , SELECT Code,Name,n.TheNature FROM dbo.Bas_Dept d,dbo.Bas_DeptNature n WHERE d.ID=n.IdDept AND n.TheNature AND n.TheNature= 门诊 AND d.TheRemark=平板问卷 , , all , Code, Name, 请选择科室 ); 参数含义依次为: 所要绑定的元素名、表名(也可以是 SQL查询语句) 、条件、默认要显示内容的索引,要传的值,显示
2、的内容 ,,默认显示的内容;3 LoadComboBoxAADept方法里的内容【写在 js 里的】function LoadComboBoxAADept(obj, entity, fiter, select, id, text, top) $( # + obj + ).combobox( url: webroot + /Ashx/Common/SatiRateReport.ashx?Method=LoadComboAADept&entity= + encodeURI(entity) + &fiter= + encodeURI(fiter) + &select= + encodeURI(sel
3、ect) + &id= + id + &text= + text + &top= + encodeURI(top) + , valueField: id , textField: text , editable: true , mode: remote); Ashx 里的内容:/ 科室下拉框,根据科室性质,显示门诊或住院的科室 l.mt 2017-03-28publicvoid LoadComboAADept() /TheRemarkstring entity = Server.UrlDecode(Request entity ).Replace( , + ); ; string fiter
4、= Server.UrlDecode(Request fiter ); ; string q = Server.UrlDecode(Request q ); ; string select = Server.UrlDecode(Request select ); ; string id = Server.UrlDecode(Request id ); ; string text = Server.UrlDecode(Request text ).Replace( , + ); string top = Server.UrlDecode(Request top ); string sql = s
5、tring .Empty; if (! string .IsNullOrEmpty(fiter) sql = entity + where + fiter + ; elsesql = entity ; if (! string .IsNullOrEmpty(q) sql += and (PyCode like % + q + % or WbCode like % + q + % or Name like % + q + % ) ; string excute = string .Empty; excute = select + id + id , + text + text from ( +
6、sql + ) as T ; DataTable dt = KBT.Utility. SqlHelper .ExecuteDataSet(excute).Tables0; StringBuilder comboData = newStringBuilder (); / comboData.Append();if (! string .IsNullOrEmpty(top) if (select = all ) comboData.Append( id: all, text: + top + , selected: true ); elsecomboData.Append( id: all, te
7、xt: + top + ); if (dt.Rows.Count 0) for ( int i = 0; i dt.Rows.Count - 1; i+) if (select = dt.Rowsi id .ToString().Trim() | select = i.ToString() comboData.Append( , id: + dt.Rowsi id .ToString() + , text: + dt.Rowsi text .ToString() + , selected: true ); elsecomboData.Append( , id: + dt.Rowsi id .T
8、oString() + , text: + dt.Rowsi text .ToString() + ); if (select = dt.Rowsdt.Rows.Count - 1 id .ToString().Trim() | select = (dt.Rows.Count - 1).ToString() comboData.Append( , id: + dt.Rowsdt.Rows.Count - 1 id .ToString() + , text: + dt.Rowsdt.Rows.Count - 1 text .ToString() + , selected: true ); els
9、ecomboData.Append( , id: + dt.Rowsdt.Rows.Count - 1 id .ToString() + , text: + dt.Rowsdt.Rows.Count - 1 text .ToString() + ); comboData.Append( ); if (comboData.ToString().Substring(0, 1) = , ) Response.Write( + comboData.ToString().Substring(1, comboData.ToString().Length - 1); elseResponse.Write( + comboData.ToString();