1 function Loadkeyup(e) { 2 var self =$("#"+e); 3 var val = self.combobox("getText"); 4 if (val != "") { 5 if (!val.match(/[^\u4e00-\u9fa5]/g)) { 6 if (val.length >=2) { 7 debugger; 8 self.combobox({ 9 required: true, 10 url: "/Public/GetPageList", //请求路径 11 method: ‘get‘, 12 valueField: ‘POST_CODE_ID_SEQ‘, 13 textField: ‘ADDRESS_TEXT‘, 14 queryParams: { CITY_TEXT: val }, 15 onLoadSuccess: function () { 16 self.combobox("setText", val); 17 self.combobox("showPanel"); 18 self.combobox("textbox").focus(); 19 }, 20 filter: function (q, row) { 21 var opts = $(this).combobox(‘options‘); 22 return row[opts.textField].indexOf(q) > -1; 23 }, 24 onSelect: function (record) { 25 var cityName = record.ADDRESS_TEXT.split(‘,‘); 26 debugger; 27 if (cityName.length>=3) { 28 var text = cityName[1] + "," + cityName[2]; 29 $(this).combobox("setText", text); 30 $(this)[0].code = record.POST_CODE_TEXT; 31 } 32 } 33 }); 34 35 } 36 } 37 } 38 }
1. 当用户输入两个汉字时再去加载后台数据,根据输入内容作为查询条件queryParams的参数是对象。combbox依赖comb,comb依赖panel。2. $(this)[0].code是给函数自定义的名称,用来存储临时变量,取数据时 $("#START_STATION_TEXT")[0].code。
<div style=" display:inline-block;" onkeyup="Loadkeyup(‘START_STATION_TEXT‘)"> <input class="easyui-combobox" type="text" id="START_STATION_TEXT" name="START_STATION_TEXT" style="width: 150px;" /></div>
3. 方法参数传递下拉框id名称。
时间: 2024-10-03 23:00:24