a27e0ac96f9eca8022970b19fb446cf946b051ae.svn-base 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title></title>
  6. <!--框架必需start-->
  7. <script type="text/javascript" src="../../libs/js/jquery.js"></script>
  8. <script type="text/javascript" src="../../libs/js/language/cn.js"></script>
  9. <script type="text/javascript" src="../../libs/js/framework.js"></script>
  10. <link href="../../libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
  11. <link rel="stylesheet" type="text/css" id="skin" prePath="../../"/>
  12. <link rel="stylesheet" type="text/css" id="customSkin"/>
  13. <!--框架必需end-->
  14. <!--提示下拉框start-->
  15. <script type='text/javascript' src='../../libs/js/form/selectSuggestion.js'></script>
  16. <!--提示下拉框end-->
  17. </head>
  18. <body>
  19. <div class="box1" panelWidth="800">
  20. <fieldset>
  21. <legend>说明</legend>
  22. 提示下拉框点击右侧箭头按钮展开下拉列表,点击文本框可以进行输入过滤。<br/>
  23. 默认有输入验证功能,即输入的文本在列表里面不存在时,会自动清除。此功能可禁用,这时可以输入任意文本。<br/>
  24. 相比单选下拉框组件,除了有输入提示功能外,还有选项标签式分组,数据列表分页,键盘操作进行翻页和选中等额外功能(键盘操作在点击文本框展开列表时有效,点击按钮时无效)。缺少联动,动态修改选项功能。<br/>
  25. </fieldset>
  26. <div class="height_15"></div>
  27. <fieldset>
  28. <legend>1、通过url获取数据源</legend>
  29. <div class="red">此示例由后台支持</div>
  30. <!--
  31. <div class="selectSuggestion" url="../../autoComplateAction.do?method=getListOfCity" id="sug-1"></div>
  32. <input type="button" value="获取值" onclick="getValue()" />
  33. <br/>还可通过url+参数获取数据源,用法同单选下拉框
  34. -->
  35. </fieldset>
  36. <div class="height_15"></div>
  37. <fieldset>
  38. <legend>2、通过设置data数据获取数据源</legend>
  39. <div class="selectSuggestion" id="suggestion2" keepDefaultStyle="true"></div>
  40. </fieldset>
  41. <div class="height_15"></div>
  42. <fieldset>
  43. <legend>3、点击文本框显示下拉列表</legend>
  44. <div class="selectSuggestion" id="suggestion3" keepDefaultStyle="true" showList="true"></div>
  45. <br/>
  46. 设置showList属性为true,点击文本框也会出现下拉列表。<br/>
  47. 当点击文本框出现下拉列表时,可以使用键盘操作进行翻页和选中。
  48. </fieldset>
  49. <div class="height_15"></div>
  50. <fieldset>
  51. <legend>4、不允许输入过滤</legend>
  52. <div class="selectSuggestion" id="suggestion4" keepDefaultStyle="true" suggestable="false" prompt="请选择" autoCheck="false" pageNum="50" openDirection="bottom"></div>
  53. <br/>
  54. 此时等同于基本的单选下拉框,并且这里自定义下拉列表每页50条记录,不足50条不出现分页按钮。
  55. </fieldset>
  56. <div class="height_15"></div>
  57. <fieldset>
  58. <legend>5、禁用/启用</legend>
  59. <div class="selectSuggestion" disabled="true" id="suggestion5" keepDefaultStyle="true"></div>
  60. <br/>
  61. <input type="button" value="启用" onclick="enableSelect()" style="width:105px;"/>
  62. <input type="button" value="禁用" onclick="disableSelect()" style="width:105px;"/>
  63. </fieldset>
  64. <div class="height_15"></div>
  65. <fieldset>
  66. <legend>6、选中事件</legend>
  67. <div class="selectSuggestion" id="suggestion6" keepDefaultStyle="true"></div>
  68. </fieldset>
  69. <div class="height_15"></div>
  70. <fieldset>
  71. <legend>7、宽度、高度与方向</legend>
  72. 下拉框默认有一个宽度(每种风格皮肤下默认宽度可能不一样),当有较长的选项时,下拉框宽度默认不变,而选项容器宽度自适应<br/>
  73. <div class="selectSuggestion" id="suggestion7-1" keepDefaultStyle="true"></div>
  74. <br/><br/>
  75. 单独设置下拉框宽度,选项容器宽度默认不会小于下拉框宽度<br/>
  76. <div class="selectSuggestion" id="suggestion7-2" keepDefaultStyle="true" selWidth="260"></div>
  77. <br/><br/>自定义容器高度:<br/>
  78. <div class="selectSuggestion" id="suggestion7-3" keepDefaultStyle="true" boxHeight="100"></div>
  79. <br/><br/>强制向上展开:<br/>
  80. <div class="selectSuggestion" id="suggestion7-4" keepDefaultStyle="true" openDirection="top"></div>
  81. </fieldset>
  82. <div class="height_15"></div>
  83. <fieldset>
  84. <legend>8、自定义下拉列表数据</legend>
  85. <div class="selectSuggestion" id="suggestion8" keepDefaultStyle="true"></div>
  86. <br/>
  87. 可以设置点击出现的下拉列表数据,例如当全部列表数据数据量很大时,点击下拉只显示推荐的数据。<br/>
  88. 当输入过滤时,再从全部的数据里面过滤。
  89. </fieldset>
  90. <div class="height_15"></div>
  91. <fieldset>
  92. <legend>9、自定义列数</legend>
  93. <div class="selectSuggestion" id="suggestion9" keepDefaultStyle="true" showMultiList="true" multiListWidth="300"></div>
  94. <br/>
  95. 设置showMultiList属性为true后,点击下拉的选项列表为多列。需要设置列表总宽度。<br/>
  96. 多列下拉列表无分页功能,并且需要设置列表的尺寸
  97. </fieldset>
  98. <div class="height_15"></div>
  99. <fieldset>
  100. <legend>10、选项标签式分组</legend>
  101. <div class="selectSuggestion" id="suggestion10" keepDefaultStyle="true" showMultiList="true" multiListWidth="300" multiListHeight="200"></div>
  102. <br/>
  103. 可以为组件多列下拉列表设置一个分组的数据,实现下拉列表的分组。
  104. </fieldset>
  105. <div class="height_15"></div>
  106. <fieldset>
  107. <legend>11、将下拉列表渲染为图片+文字</legend>
  108. <div class="selectSuggestion" id="suggestion11" renderMode="pic" boxWidth="330" keepDefaultStyle="true" itemHeight="90" itemWidth="75" pageNum="9"></div>
  109. </fieldset>
  110. <div class="height_15"></div>
  111. <fieldset>
  112. <legend>12、设置初始值</legend>
  113. <div class="selectSuggestion" id="suggestion12" keepDefaultStyle="true" selectedValue="4"></div>
  114. </fieldset>
  115. <div class="height_15"></div>
  116. <fieldset>
  117. <legend>13、取消自动验证</legend>
  118. <div class="selectSuggestion" id="suggestion13" keepDefaultStyle="true" autoCheck="false"></div>
  119. <input type="button" value="获取值" onclick="getValue2()" />
  120. <br/>
  121. 这时可以输入下拉列表没有的文本。
  122. </fieldset>
  123. <div class="height_15"></div>
  124. <fieldset>
  125. <legend>14、自定义验证</legend>
  126. <div class="selectSuggestion" id="suggestion14" keepDefaultStyle="true" autoCheck="false"></div>
  127. <br/>
  128. 通过自定义验证,可以用ajax方式将输入的值提交到后台检验数据库中是否存在该文本,如果存在,将对应的value返回通知页面是选择的;如果不存在,通知页面是输入的,提交时可以为选项表添加记录。<br/>
  129. </fieldset>
  130. <div class="height_15"></div>
  131. <fieldset>
  132. <legend>15、动态创建</legend>
  133. <input type="button" value="点击生成" id="testBtn" onclick="dynamic()" style="width:150px;"/>
  134. </fieldset>
  135. <div class="height_15"></div>
  136. <fieldset>
  137. <legend>16、获得选中节点自定义属性</legend>
  138. <div class="selectSuggestion" id="suggestion16" keepDefaultStyle="true" ></div>
  139. </fieldset>
  140. <div class="height_15"></div>
  141. <fieldset>
  142. <legend>17、无前缀数据</legend>
  143. <div class="selectSuggestion" id="suggestion17" keepDefaultStyle="true" showMultiList="true" multiListWidth="300" multiListHeight="200"></div>
  144. </fieldset>
  145. <div class="height_50"></div>
  146. <script>
  147. var listdata={"list":[
  148. {value:"1",key:"北京",suggest:"北京|beijing|bj"},
  149. {value:"2",key:"广州",suggest:"广州|guangzhou|gz"},
  150. {value:"3",key:"深圳",suggest:"深圳|shenzhen|sz"},
  151. {value:"4",key:"上海",suggest:"上海|shanghai|sh"},
  152. {value:"5",key:"长沙",suggest:"长沙|changsha|cs"},
  153. {value:"6",key:"成都",suggest:"成都|chengdu|cd"},
  154. {value:"7",key:"贵阳",suggest:"贵阳|guiyang|gy"},
  155. {value:"8",key:"海口",suggest:"海口|haikou|hk"},
  156. {value:"9",key:"杭州",suggest:"杭州|hangzhou|hz"},
  157. {value:"10",key:"昆明",suggest:"昆明|kunming|km"},
  158. {value:"11",key:"南昌",suggest:"南昌|nanchang|nc"},
  159. {value:"12",key:"南京",suggest:"南京|nanjing|nj"},
  160. {value:"13",key:"三亚",suggest:"三亚|sanya|sy"},
  161. {value:"14",key:"沈阳",suggest:"沈阳|shenyang|sy"},
  162. {value:"15",key:"温州",suggest:"温州|wenzhou|wz"},
  163. {value:"16",key:"武汉",suggest:"武汉|wuhan|wh"},
  164. {value:"17",key:"厦门",suggest:"厦门|xiamen|xm"},
  165. {value:"18",key:"西安",suggest:"西安|xian|xa"},
  166. {value:"19",key:"郑州",suggest:"郑州|zhenghou|zz"},
  167. {value:"20",key:"汕头",suggest:"汕头|shantou|st"},
  168. {value:"21",key:"太原",suggest:"太原|taiyuan|ty"},
  169. {value:"22",key:"天津",suggest:"天津|tianjin|tj"}]};
  170. var hotdata={"list":[
  171. {value:"1",key:"北京"},
  172. {value:"2",key:"广州"},
  173. {value:"3",key:"深圳"},
  174. {value:"4",key:"上海"}]};
  175. var tabdata={list:[
  176. {name:"热门城市",tab:[
  177. {key:"北京",value:"1"},
  178. {key:"广州",value:"2"},
  179. {key:"深圳",value:"3"},
  180. {key:"上海",value:"4"},
  181. {key:"成都",value:"6"},
  182. {key:"杭州",value:"9"},
  183. {key:"三亚",value:"13"},
  184. {key:"天津",value:"22"},
  185. {key:"厦门",value:"17"},
  186. {key:"西安",value:"18"}
  187. ]},
  188. {name:"A-F",tab:[
  189. {key:"北京",value:"1"},
  190. {key:"长沙",value:"5"},
  191. {key:"成都",value:"6"}
  192. ]},
  193. {name:"G-J",tab:[
  194. {key:"广州",value:"2"},
  195. {key:"贵阳",value:"7"},
  196. {key:"海口",value:"8"},
  197. {key:"杭州",value:"9"}
  198. ]},
  199. {name:"K-N",tab:[
  200. {key:"昆明",value:"10"},
  201. {key:"南昌",value:"11"},
  202. {key:"南京",value:"12"}
  203. ]},
  204. {name:"O-T",tab:[
  205. {key:"深圳",value:"3"},
  206. {key:"上海",value:"4"},
  207. {key:"三亚",value:"13"},
  208. {key:"沈阳",value:"14"},
  209. {key:"汕头",value:"20"},
  210. {key:"太原",value:"21"},
  211. {key:"天津",value:"22"}
  212. ]},
  213. {name:"U-Z",tab:[
  214. {key:"温州",value:"15"},
  215. {key:"武汉",value:"16"},
  216. {key:"厦门",value:"17"},
  217. {key:"西安",value:"18"},
  218. {key:"郑州",value:"19"}
  219. ]}
  220. ]}
  221. var listdata2=[
  222. {value:"1",key:"北京",suggest:"北京|beijing|bj"},
  223. {value:"2",key:"广州",suggest:"广州|guangzhou|gz"},
  224. {value:"3",key:"深圳",suggest:"深圳|shenzhen|sz"},
  225. {value:"4",key:"上海",suggest:"上海|shanghai|sh"},
  226. {value:"5",key:"长沙",suggest:"长沙|changsha|cs"},
  227. {value:"6",key:"成都",suggest:"成都|chengdu|cd"},
  228. {value:"7",key:"贵阳",suggest:"贵阳|guiyang|gy"},
  229. {value:"8",key:"海口",suggest:"海口|haikou|hk"},
  230. {value:"9",key:"杭州",suggest:"杭州|hangzhou|hz"},
  231. {value:"10",key:"昆明",suggest:"昆明|kunming|km"},
  232. {value:"11",key:"南昌",suggest:"南昌|nanchang|nc"},
  233. {value:"12",key:"南京",suggest:"南京|nanjing|nj"},
  234. {value:"13",key:"三亚",suggest:"三亚|sanya|sy"},
  235. {value:"14",key:"沈阳",suggest:"沈阳|shenyang|sy"},
  236. {value:"15",key:"温州",suggest:"温州|wenzhou|wz"},
  237. {value:"16",key:"武汉",suggest:"武汉|wuhan|wh"},
  238. {value:"17",key:"厦门",suggest:"厦门|xiamen|xm"},
  239. {value:"18",key:"西安",suggest:"西安|xian|xa"},
  240. {value:"19",key:"郑州",suggest:"郑州|zhenghou|zz"},
  241. {value:"20",key:"汕头",suggest:"汕头|shantou|st"},
  242. {value:"21",key:"太原",suggest:"太原|taiyuan|ty"},
  243. {value:"22",key:"天津",suggest:"天津|tianjin|tj"}];
  244. var tabdata2=[
  245. {name:"热门城市",tab:[
  246. {key:"北京",value:"1"},
  247. {key:"广州",value:"2"},
  248. {key:"深圳",value:"3"},
  249. {key:"上海",value:"4"},
  250. {key:"成都",value:"6"},
  251. {key:"杭州",value:"9"},
  252. {key:"三亚",value:"13"},
  253. {key:"天津",value:"22"},
  254. {key:"厦门",value:"17"},
  255. {key:"西安",value:"18"}
  256. ]},
  257. {name:"A-F",tab:[
  258. {key:"北京",value:"1"},
  259. {key:"长沙",value:"5"},
  260. {key:"成都",value:"6"}
  261. ]},
  262. {name:"G-J",tab:[
  263. {key:"广州",value:"2"},
  264. {key:"贵阳",value:"7"},
  265. {key:"海口",value:"8"},
  266. {key:"杭州",value:"9"}
  267. ]},
  268. {name:"K-N",tab:[
  269. {key:"昆明",value:"10"},
  270. {key:"南昌",value:"11"},
  271. {key:"南京",value:"12"}
  272. ]},
  273. {name:"O-T",tab:[
  274. {key:"深圳",value:"3"},
  275. {key:"上海",value:"4"},
  276. {key:"三亚",value:"13"},
  277. {key:"沈阳",value:"14"},
  278. {key:"汕头",value:"20"},
  279. {key:"太原",value:"21"},
  280. {key:"天津",value:"22"}
  281. ]},
  282. {name:"U-Z",tab:[
  283. {key:"温州",value:"15"},
  284. {key:"武汉",value:"16"},
  285. {key:"厦门",value:"17"},
  286. {key:"西安",value:"18"},
  287. {key:"郑州",value:"19"}
  288. ]}
  289. ]
  290. var listdata3={"list":[
  291. {value:"1",key:"北京市海淀区北四环西路9号银谷大厦8层",suggest:"北京|beijing|bj"},
  292. {value:"2",key:"广州市西路9号银谷大厦8层",suggest:"广州|guangzhou|gz"},
  293. {value:"3",key:"深圳市西路9号银谷大厦8层",suggest:"深圳|shenzhen|sz"},
  294. {value:"4",key:"上海市西路9号银谷大厦8层",suggest:"上海|shanghai|sh"},
  295. {value:"5",key:"长沙市西路9号银谷大厦8层",suggest:"长沙|changsha|cs"}]};
  296. var listdata4={"list":[
  297. {value:"1",key:"北京",suggest:"北京|beijing|bj",custom:"北京自定义属性"},
  298. {value:"2",key:"广州",suggest:"广州|guangzhou|gz",custom:"广州自定义属性"},
  299. {value:"3",key:"深圳",suggest:"深圳|shenzhen|sz",custom:"深圳自定义属性"}]};
  300. var listdata5={"list":[
  301. {value:"1",key:"北京",suggest:"北京|beijing|bj",img:"../../libs/icons/png_64/11.png"},
  302. {value:"2",key:"广州",suggest:"广州|guangzhou|gz",img:"../../libs/icons/png_64/12.png"},
  303. {value:"3",key:"深圳",suggest:"深圳|shenzhen|sz",img:"../../libs/icons/png_64/13.png"},
  304. {value:"4",key:"上海",suggest:"上海|shanghai|sh",img:"../../libs/icons/png_64/14.png"},
  305. {value:"5",key:"长沙",suggest:"长沙|changsha|cs",img:"../../libs/icons/png_64/15.png"},
  306. {value:"6",key:"成都",suggest:"成都|chengdu|cd",img:"../../libs/icons/png_64/16.png"},
  307. {value:"7",key:"贵阳",suggest:"贵阳|guiyang|gy",img:"../../libs/icons/png_64/17.png"},
  308. {value:"8",key:"海口",suggest:"海口|haikou|hk",img:"../../libs/icons/png_64/18.png"},
  309. {value:"9",key:"杭州",suggest:"杭州|hangzhou|hz",img:"../../libs/icons/png_64/19.png"},
  310. {value:"10",key:"昆明",suggest:"昆明|kunming|km",img:"../../libs/icons/png_64/20.png"},
  311. {value:"11",key:"南昌",suggest:"南昌|nanchang|nc",img:"../../libs/icons/png_64/21.png"},
  312. {value:"12",key:"南京",suggest:"南京|nanjing|nj",img:"../../libs/icons/png_64/22.png"},
  313. {value:"13",key:"三亚",suggest:"三亚|sanya|sy",img:"../../libs/icons/png_64/23.png"},
  314. {value:"14",key:"沈阳",suggest:"沈阳|shenyang|sy",img:"../../libs/icons/png_64/24.png"},
  315. {value:"15",key:"温州",suggest:"温州|wenzhou|wz",img:"../../libs/icons/png_64/25.png"},
  316. {value:"16",key:"武汉",suggest:"武汉|wuhan|wh",img:"../../libs/icons/png_64/26.png"},
  317. {value:"17",key:"厦门",suggest:"厦门|xiamen|xm",img:"../../libs/icons/png_64/27.png"},
  318. {value:"18",key:"西安",suggest:"西安|xian|xa",img:"../../libs/icons/png_64/28.png"},
  319. {value:"19",key:"郑州",suggest:"郑州|zhenghou|zz",img:"../../libs/icons/png_64/29.png"},
  320. {value:"20",key:"汕头",suggest:"汕头|shantou|st",img:"../../libs/icons/png_64/30.png"},
  321. {value:"21",key:"太原",suggest:"太原|taiyuan|ty",img:"../../libs/icons/png_64/31.png"},
  322. {value:"22",key:"天津",suggest:"天津|tianjin|tj",img:"../../libs/icons/png_64/32.png"}]};
  323. function initComplete(){
  324. $("#suggestion2").data("data",listdata);
  325. $("#suggestion2").render();
  326. $("#suggestion3").data("data",listdata);
  327. $("#suggestion3").render();
  328. $("#suggestion4").data("data",listdata);
  329. $("#suggestion4").render();
  330. $("#suggestion5").data("data",listdata);
  331. $("#suggestion5").render();
  332. $("#suggestion6").data("data",listdata);
  333. $("#suggestion6").render();
  334. $("#suggestion6").bind("listSelect",function(e,obj){
  335. top.Dialog.alert("选中项文本:"+obj.relText+";选中项值:"+obj.relValue);
  336. })
  337. $("#suggestion7-1").data("data",listdata3);
  338. $("#suggestion7-1").render();
  339. $("#suggestion7-2").data("data",listdata3);
  340. $("#suggestion7-2").render();
  341. $("#suggestion7-3").data("data",listdata);
  342. $("#suggestion7-3").render();
  343. $("#suggestion7-4").data("data",listdata);
  344. $("#suggestion7-4").render();
  345. $("#suggestion8").data("data",listdata);
  346. $("#suggestion8").data("list",hotdata);
  347. $("#suggestion8").render();
  348. $("#suggestion9").data("data",listdata);
  349. $("#suggestion9").render();
  350. $("#suggestion10").data("data",listdata);
  351. $("#suggestion10").data("tab",tabdata);
  352. $("#suggestion10").render();
  353. $("#suggestion11").data("data",listdata5);
  354. $("#suggestion11").selectSuggestionRender();
  355. $("#suggestion12").data("data",listdata);
  356. $("#suggestion12").render();
  357. $("#suggestion13").data("data",listdata);
  358. $("#suggestion13").render();
  359. $("#suggestion14").data("data",listdata);
  360. $("#suggestion14").render();
  361. $("#suggestion14").bind("validate",function(e,value){
  362. top.Dialog.alert("此处触发验证事件,可以用ajax方式将”"+value+"“提交到后台处理。")
  363. })
  364. $("#suggestion16").data("data",listdata4);
  365. $("#suggestion16").render();
  366. $("#suggestion16").bind("listSelect",function(e,obj){
  367. var node=$("#suggestion16").data("selectedNode");
  368. top.Dialog.alert(node.custom);
  369. })
  370. $("#suggestion17").data("data",listdata2);
  371. $("#suggestion17").data("tab",tabdata2);
  372. $("#suggestion17").render();
  373. }
  374. function getValue(){
  375. top.Dialog.alert("选中文本:"+$("#sug-1").attr("relText")+"<br/>选中值:"+$("#sug-1").attr("relValue"));
  376. }
  377. function getValue2(){
  378. top.Dialog.alert("输入文本:"+$("#suggestion13").attr("relText"));
  379. }
  380. //设为不可用
  381. function disableSelect(){
  382. $("#suggestion5").attr("disabled",true);
  383. $("#suggestion5").render();
  384. }
  385. //设为可用
  386. function enableSelect(){
  387. $("#suggestion5").attr("disabled",false);
  388. $("#suggestion5").render();
  389. }
  390. //动态生成
  391. function dynamic(){
  392. var $sugg = $('<div type="text" class="selectSuggestion"></div>');
  393. $sugg.data("data",listdata);
  394. $("#testBtn").after($sugg);
  395. $("#testBtn").after($("<br/>"));
  396. //渲染
  397. $sugg.render();
  398. }
  399. </script>
  400. </body>
  401. </html>