4fff2fe24c5c439684805cc94b20e5f6c2f07d2a.svn-base 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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/lister.js"></script>
  16. <!-- 双向选择器end -->
  17. </head>
  18. <body>
  19. <div class="box1" panelWidth="800">
  20. <fieldset>
  21. <legend>1、使用url赋值</legend>
  22. <div class="red">此示例由后台支持</div>
  23. <!--
  24. <div class="lister" id="lister1" url="../../userAction.do?method=getUsersOfDoubleSelect"></div>
  25. <input type="button" value="获取值" onclick="getValue()"/>
  26. <input type="button" value="获取选中项文本" onclick="getText()"/>
  27. <input type="button" value="获取选中项数据" onclick="getData()"/>
  28. -->
  29. </fieldset>
  30. <div class="height_15"></div>
  31. <fieldset>
  32. <legend>2、使用url+参数赋值</legend>
  33. <div class="red">此示例由后台支持</div>
  34. <!--
  35. <div class="lister" url="../../userAction.do?method=getUsersOfDoubleSelect" params='{"userinfor.organization.orgId":"3"}'></div>
  36. -->
  37. </fieldset>
  38. <div class="height_15"></div>
  39. <fieldset>
  40. <legend>3、赋值给标签的data属性</legend>
  41. <div class="lister" data='{"fromList":[{"value":"1","key":"员工1"},{"value":"2","key":"员工2"},{"value":"3","key":"员工3"},{"value":"4","key":"员工4"}],"toList":[]}'></div>
  42. </fieldset>
  43. <div class="height_15"></div>
  44. <fieldset>
  45. <legend>4、动态设置data(本地数据源)</legend>
  46. <div class="lister" id="lister4" keepDefaultStyle="true"></div>
  47. </fieldset>
  48. <div class="height_15"></div>
  49. <fieldset>
  50. <legend>5、动态设置data(远程数据源)</legend>
  51. <div class="red">此示例由后台支持</div>
  52. <div class="lister" id="lister5" keepDefaultStyle="true"></div>
  53. </fieldset>
  54. <div class="height_15"></div>
  55. <fieldset>
  56. <legend>6、初始时存在已选值</legend>
  57. <p>通过设置数据的toList内容来实现已选值</p>
  58. <div class="lister" data='{"fromList":[{"value":"1","key":"员工1"},{"value":"2","key":"员工2"}],"toList":[{"value":"3","key":"员工3"},{"value":"4","key":"员工4"}]}'></div>
  59. <br/> <br/>
  60. <p>通过设置selectedValue实现已选值</p>
  61. <div class="lister" selectedValue="1,2" data='{"fromList":[{"value":"1","key":"员工1"},{"value":"2","key":"员工2"},{"value":"3","key":"员工3"},{"value":"4","key":"员工4"}],"toList":[]}'></div>
  62. <br/>使用selectedValue实现了已选值,在操作后再使用render()方法刷新后可以还原为初始值。参见最后一个例子:重置双选器。
  63. <br/>通过设置数据的toList内容来实现已选值则不可以还原。
  64. <br/><br/>另外 如果希望表单重置时已选值清空,需要设置selectedValue=""
  65. </fieldset>
  66. <div class="height_15"></div>
  67. <fieldset>
  68. <legend>7、使用隐藏域</legend>
  69. <p>如果为组件添加name属性,那么会自动生成一个隐藏域input,用来存储组件当前的value,该input的name与组件name一致。<br/>在提交表单时会用到。</p>
  70. <div class="lister" name="lister7" data='{"fromList":[{"value":"1","key":"员工1"},{"value":"2","key":"员工2"},{"value":"3","key":"员工3"},{"value":"4","key":"员工4"}],"toList":[]}'></div>
  71. <input type="button" value="获取隐藏域选中值" onclick="getHiddenValue()"/>
  72. </fieldset>
  73. <div class="height_15"></div>
  74. <fieldset>
  75. <legend>8、禁用/启用</legend>
  76. <div class="lister" disabled="true" id="lister8" data='{"fromList":[{"value":"1","key":"员工1"},{"value":"2","key":"员工2"},{"value":"3","key":"员工3"},{"value":"4","key":"员工4"}],"toList":[]}'></div>
  77. <br/>
  78. <input type="button" value="启用" onclick="enableLister()" style="width:120px;"/>
  79. <input type="button" value="禁用" onclick="disableLister()" style="width:120px;"/>
  80. </fieldset>
  81. <div class="height_15"></div>
  82. <fieldset>
  83. <legend>9、自定义尺寸</legend>
  84. <div class="lister" listerWidth="120" listerHeight="120" data='{"fromList":[{"value":"1","key":"员工1"},{"value":"2","key":"员工2"},{"value":"3","key":"员工3"},{"value":"4","key":"员工4"}],"toList":[]}'></div>
  85. </fieldset>
  86. <div class="height_15"></div>
  87. <fieldset>
  88. <legend>10、动态生成双选器</legend>
  89. <div class="red">此示例由后台支持</div>
  90. <input type="button" value="点击生成(使用url)" id="testBtn" onclick="dynamicLister1()" style="width:150px;"/><br/><br/>
  91. <input type="button" value="点击生成(使用data)" id="testBtn2" onclick="dynamicLister2()" style="width:150px;"/><br/><br/>
  92. </fieldset>
  93. <div class="height_15"></div>
  94. <fieldset>
  95. <legend>11、动态改变值</legend>
  96. <div class="lister" id="lister11" data='{"fromList":[{"value":"2","key":"员工2"},{"value":"3","key":"员工3"},{"value":"4","key":"员工4"}],"toList":[{"value":"1","key":"员工1"}]}'></div>
  97. <br/>
  98. <input type="button" value="选中“员工2,员工3”" onclick="selectItems()" style="width:120px;"/>
  99. <input type="button" value="反选“员工1”" onclick="unSelectItems()" style="width:120px;"/>
  100. <input type="button" value="设值为“员工1,员工4”"" onclick="setValues()" style="width:120px;"/>
  101. <br/>
  102. <br/>
  103. <br/>
  104. <input type="button" value="追加一项到左侧" onclick="appendItem()" style="width:120px;"/>
  105. <input type="button" value="从左侧移除“员工2”" onclick="removeItem()" style="width:120px;"/>
  106. </fieldset>
  107. <div class="height_15"></div>
  108. <fieldset>
  109. <legend>12、重置双选器</legend>
  110. <form id="form-12">
  111. <table class="tableStyle" formMode="transparent" style="width:500px;">
  112. <tr>
  113. <td>传统表单元素:</td>
  114. <td><input type="text"/></td>
  115. </tr>
  116. <tr>
  117. <td>双向选择器1:</td>
  118. <td><div class="lister" selectedValue="" listerWidth="120" listerHeight="120" fromTitle="" toTitle="" data='{"fromList":[{"value":"1","key":"员工1"},{"value":"2","key":"员工2"},{"value":"3","key":"员工3"},{"value":"4","key":"员工4"}],"toList":[]}'></div></td>
  119. </tr>
  120. <tr>
  121. <td>双向选择器2:</td>
  122. <td><div class="lister" selectedValue="1,2" listerWidth="120" listerHeight="120" fromTitle="" toTitle="" data='{"fromList":[{"value":"1","key":"员工1"},{"value":"2","key":"员工2"},{"value":"3","key":"员工3"},{"value":"4","key":"员工4"}],"toList":[]}'></div></td>
  123. </tr>
  124. <tr>
  125. <td colspan="2">
  126. <input type="button" value="提交"/>
  127. <input type="button" value="重置" onclick="resetForm()"/>
  128. </td>
  129. </tr>
  130. </table>
  131. </form>
  132. </fieldset>
  133. <div class="height_15"></div>
  134. <fieldset>
  135. <legend>13、itemClick事件</legend>
  136. <div class="lister" id="lister-13" data='{"fromList":[{"value":"1","key":"员工1"},{"value":"2","key":"员工2"},{"value":"3","key":"员工3"},{"value":"4","key":"员工4"}],"toList":[]}'></div>
  137. </fieldset>
  138. <div class="height_15"></div>
  139. <fieldset>
  140. <legend>14、设置最大可选条数</legend>
  141. <div class="lister" maxSelection="3" data='{"fromList":[{"value":"1","key":"员工1"},{"value":"2","key":"员工2"},{"value":"3","key":"员工3"},{"value":"4","key":"员工4"}],"toList":[]}'></div>
  142. </fieldset>
  143. </div>
  144. <script>
  145. function initComplete(){
  146. var selData={fromList:[{value:"1",key:"员工1"},{value:"2",key:"员工2"},{value:"3",key:"员工3"},{value:"4",key:"员工4"}],"toList":[]};
  147. $("#lister4").data("data",selData)
  148. $("#lister4").render();
  149. //获取json数据
  150. /*
  151. $.post("../../userAction.do?method=getUsersOfDoubleSelect",{"userinfor.organization.orgId":"2"},function(result){
  152. //赋给data属性
  153. $("#lister5").data("data",result)
  154. //刷新下拉框
  155. $("#lister5").render();
  156. },"json");
  157. */
  158. $("#lister-13").bind("itemClick",function(e){
  159. alert("触发事件")
  160. })
  161. }
  162. //获取值
  163. function getValue(){
  164. top.Dialog.alert($("#lister1").attr("relValue"));
  165. }
  166. //获取文本
  167. function getText(){
  168. top.Dialog.alert($("#lister1").attr("relText"));
  169. }
  170. //获取数据
  171. function getData(){
  172. alert(JSON.stringify($("#lister1").data("selectedNodes")));
  173. }
  174. //获取隐藏域值
  175. function getHiddenValue(){
  176. top.Dialog.alert($("input:hidden[name='lister7']").val());
  177. }
  178. //动态禁用/启用
  179. function disableLister(){
  180. $("#lister8").attr("disabled",true);
  181. //刷新双选器
  182. $("#lister8").render();
  183. }
  184. function enableLister(){
  185. $("#lister8").attr("disabled",false);
  186. //刷新双选器
  187. $("#lister8").render();
  188. }
  189. //动态生成双选器
  190. function dynamicLister1(){
  191. /*
  192. var $lister=$('<div class="lister"></div>');
  193. $lister.attr("url","../../userAction.do?method=getUsersOfDoubleSelect");
  194. $lister.attr("params",'{"userinfor.organization.orgId":"3"}');
  195. //将双向选择器加到按钮的后面
  196. $("#testBtn").after($lister);
  197. //渲染双向选择器
  198. $lister.render();
  199. */
  200. }
  201. function dynamicLister2(){
  202. /*
  203. $.post("../../userAction.do?method=getUsersOfDoubleSelect",{"userinfor.organization.orgId":"2"},function(result){
  204. var $lister=$('<div class="lister"></div>');
  205. //赋给data属性
  206. $lister.data("data",result)
  207. //将双向选择器加到按钮的后面
  208. $("#testBtn2").after($lister);
  209. //渲染双向选择器
  210. $lister.render();
  211. },"json");
  212. */
  213. }
  214. //动态选中
  215. function selectItems(){
  216. $("#lister11").selectValue("2,3")
  217. }
  218. //动态反选
  219. function unSelectItems(){
  220. $("#lister11").unSelectValue("1")
  221. }
  222. //动态赋值
  223. function setValues(){
  224. $("#lister11").setValue("1,4")
  225. }
  226. //添加项
  227. function appendItem(){
  228. $("#lister11").addItem({key: "员工5", value: "100"});
  229. }
  230. //删除项
  231. function removeItem(){
  232. $("#lister11").removeItem("2");
  233. }
  234. //表单重置
  235. function resetForm(){
  236. $("#form-12")[0].reset();
  237. $("#form-12 .lister").resetValue();
  238. }
  239. </script>
  240. </body>
  241. </html>