1. $.fn.extend({
  2. SetDict: function (option) {
  3. var txtControl = $(this);
  4. if (!txtControl.hasClass("combo-text")) {
  5. // var width = txtControl.width();
  6. //txtControl.addClass("combo");
  7.  
  8. }
  9. txtControl.click(function () {
  10. var obj = option.valueControl;
  11. var dicType = option.dicType;
  12. var isShow = txtControl.attr("isShow");
  13. if (isShow == null || isShow == "") {
  14. txtControl.attr("isShow", "");
  15. txtControl.combogrid({
  16. panelWidth: ,
  17. idField: 'Code',
  18. textField: 'Name',
  19. url: '/Common/EntityJsonList.ashx?_method=dict&dictType=' + dicType + "&tmp=" + Math.random() + '&queryTextFild=Name',
  20. method: 'get',
  21. delay: ,
  22. columns: [[
  23. { field: 'Name', title: '名称', width: },
  24. { field: 'Code', title: '编码', width: }
  25. ]],
  26. striped: true,
  27. editable: true,
  28. collapsible: false, //是否可折叠的
  29. fit: true,
  30. onLoadSuccess: function () {
  31. window.setTimeout(function () {
  32. $(".combo-arrow", option.valueControl.parent()).click();
  33. }, );
  34. },
  35. onClickRow: function (index, row) {
  36. txtControl.val(row.Name);
  37. option.valueControl.val(row.Code);
  38. }, //自动大小
  39. keyHandler: {
  40. up: function () { //【向上键】押下处理
  41. //取得选中行
  42. var selected = txtControl.combogrid('grid').datagrid('getSelected');
  43. if (selected) {
  44. //取得选中行的rowIndex
  45. var index = txtControl.combogrid('grid').datagrid('getRowIndex', selected);
  46. txtControl.val(selected.Name);
  47. option.valueControl.val(selected.Code);
  48. //向上移动到第一行为止
  49. if (index > ) {
  50. txtControl.combogrid('grid').datagrid('selectRow', index - );
  51. }
  52. } else {
  53. var rows = txtControl.combogrid('grid').datagrid('getRows');
  54. txtControl.combogrid('grid').datagrid('selectRow', rows.length - );
  55.  
  56. }
  57. },
  58. down: function () { //【向下键】押下处理
  59. //取得选中行
  60. var selected = txtControl.combogrid('grid').datagrid('getSelected');
  61. if (selected) {
  62. txtControl.val(selected.Name);
  63. option.valueControl.val(selected.Code);
  64. //取得选中行的rowIndex
  65. var index = txtControl.combogrid('grid').datagrid('getRowIndex', selected);
  66. //向下移动到当页最后一行为止
  67. if (index < txtControl.combogrid('grid').datagrid('getData').rows.length - ) {
  68. txtControl.combogrid('grid').datagrid('selectRow', index + );
  69. }
  70. } else {
  71. txtControl.combogrid('grid').datagrid('selectRow', );
  72. }
  73. },
  74. enter: function () { //【回车键】押下处理
  75. txtControl.combogrid('hidePanel');
  76. var selected = txtControl.combogrid('grid').datagrid('getSelected');
  77. if (selected) {
  78. txtControl.val(selected.Name);
  79. option.valueControl.val(selected.Code);
  80. }
  81.  
  82. },
  83. query: function (keyword) { //【动态搜索】处理
  84. //设置查询参数
  85. var queryParams = txtControl.combogrid("grid").datagrid('options').queryParams;
  86. queryParams.keyword = keyword;
  87. txtControl.combogrid("grid").datagrid('options').queryParams = queryParams;
  88. //重新加载
  89. txtControl.combogrid("grid").datagrid("reload");
  90. txtControl.combogrid("setValue", keyword);
  91. }
  92. },
  93. mode: 'remote',
  94. fitColumns: true
  95. });
  96. }
  97. });
  98. }
  99. });
  100. $.fn.extend({
  101. SetCombo: function (option) {/// <reference path="../Common/JGridJson.cs" />
  102. var entityType = option.entityType;
  103. var textField = option.textField;
  104. var textControl = $(this);
  105. var panelWidth = option.panelWidth;
  106. var idFild = option.idFild;
  107. var valueControl = option.valueControl;
  108. var panelHeight = option.panelHeight;
  109. var columns = option.columns;
  110. var where = option.where;
  111. //var keyword = option.keyword;
  112. var pageSize = option.pageSize;
  113. if (option.pageSize == null) {
  114. pageSize = ;
  115. }
  116. var obj = valueControl;
  117. if (panelHeight == null) {
  118. panelHeight = ;
  119. }
  120. var url = '/common/EntityJsonList.ashx?entityType=' + option.entityType + '&_method=entity&tmp=' + Math.random() + '&queryTextFild=' + textField;
  121. if (where) {
  122. url += "&where=" + where;
  123. }
  124. if (panelWidth == null) {
  125. panelWidth = ;
  126. }
  127. if (valueControl.val() != "") {
  128. url += "&defaultValue=" + escape(valueControl.val());
  129. }
  130. var id = 'Id';
  131. if (idFild != null) {
  132. id = idFild;
  133. }
  134. url += "&idFild=" + id;
  135. textControl.click(function () {
  136. var a = textControl.attr("isShow");
  137. if (a == "" || a == null) {
  138. textControl.attr("isShow", "");
  139. textControl.combogrid({
  140. panelWidth: panelWidth,
  141. panelHeight: panelHeight,
  142. idField: id,
  143. textField: textField,
  144. url: url,
  145. method: 'get',
  146. delay: ,
  147. pagination: true, //是否分页
  148. rownumbers: true, //序号
  149. pageSize: pageSize, //每页显示的记录条数,默认为10
  150. pageList: [pageSize, , , , , , , ], //可以设置每页记录条数的列表
  151. columns: columns,
  152. striped: true,
  153. editable: true,
  154. collapsible: false, //是否可折叠的
  155. fit: true,
  156. onLoadSuccess: function () {
  157. window.setTimeout(function () {
  158. $(".combo-arrow", option.valueControl.parent()).click();
  159. }, );
  160. },
  161. onClickRow: function (index, row) {
  162. valueControl.val(UTIL.getJsonByKey(row, idFild));
  163. textControl.val(UTIL.getJsonByKey(row, textField));
  164. }, //自
  165. keyHandler: {
  166. up: function () { //【向上键】押下处理
  167. //取得选中行
  168. var selected = textControl.combogrid('grid').datagrid('getSelected');
  169. if (selected) {
  170. //取得选中行的rowIndex = txtControlex
  171. var index = combogrid('grid').datagrid('getRowIndex', selected);
  172. valueControl.val(UTIL.getJsonByKey(selected, idFild));
  173. textControl.val(UTIL.getJsonByKey(selected, textField));
  174. //向上移动到第一行为止
  175. if (index > ) {
  176. textControl.combogrid('grid').datagrid('selectRow', index - );
  177. }
  178. } else {
  179. var rows = textControl.combogrid('grid').datagrid('getRows');
  180. textControl.combogrid('grid').datagrid('selectRow', rows.length - );
  181. }
  182. },
  183. down: function () { //【向下键】押下处理
  184. //取得选中行
  185. var selected = textControl.combogrid('grid').datagrid('getSelected');
  186. if (selected) {
  187. valueControl.val(UTIL.getJsonByKey(selected, idFild));
  188. textControl.val(UTIL.getJsonByKey(selected, textField));
  189. //取得选中行的rowIndex
  190. var index = textControl.combogrid('grid').datagrid('getRowIndex', selected);
  191. //向下移动到当页最后一行为止
  192. if (index < textControl.combogrid('grid').datagrid('getData').rows.length - ) {
  193. textControl.combogrid('grid').datagrid('selectRow', index + );
  194. }
  195. } else {
  196. textControl.combogrid('grid').datagrid('selectRow', );
  197. }
  198. },
  199. enter: function () { //【回车键】押下处理
  200. textControl.combogrid('hidePanel');
  201. var selected = textControl.combogrid('grid').datagrid('getSelected');
  202. if (selected) {
  203. valueControl.val(UTIL.getJsonByKey(selected, idFild));
  204. textControl.val(UTIL.getJsonByKey(selected, textField));
  205. }
  206.  
  207. },
  208. query: function (keyword) { //【动态搜索】处理
  209. //设置查询参数
  210. var queryParams = textControl.combogrid("grid").datagrid('options').queryParams;
  211. queryParams.keyword = keyword;
  212. textControl.combogrid("grid").datagrid('options').queryParams = queryParams;
  213. //重新加载
  214. textControl.combogrid("grid").datagrid("reload");
  215. textControl.combogrid("setValue", keyword);
  216. }
  217. },
  218. mode: 'remote',
  219. fitColumns: true
  220. });
  221. }
  222. });
  223.  
  224. }
  225. });

jquery dropdownlist.js的更多相关文章

  1. jquery.validate.js表单验证

    一.用前必备官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ API: http://jquery.bassist ...

  2. MVC - 11(下)jquery.tmpl.js +ajax分页

    继续 mvc-11(上).dto:http://www.cnblogs.com/tangge/p/3840060.html jquery.tmpl.js 下载:http://pan.baidu.com ...

  3. 【转】jquery.validate.js表单验证

    一.用前必备官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ API: http://jquery.bassist ...

  4. [转]jquery.validate.js表单验证

    原文地址:https://www.cnblogs.com/si-shaohua/p/3780321.html 一.用前必备官方网站:http://bassistance.de/jquery-plugi ...

  5. jquery和Js的区别和基础操作

    jqery的语法和js的语法一样,算是把js升级了一下,这两种语法可以一起使用,只不过是用jqery更加方便 一个页面想要使用jqery的话,先要引入一下jqery包,jqery包从网上下一个就可以, ...

  6. jQuery.template.js 简单使用

    之前看了一篇文章<我们为什么要尝试前后端分离>,深有同感,并有了下面的评论: 我最近也和前端同事在讨论这个问题,比如有时候前端写好页面给后端了,然后后端把这些页面拆分成很多的 views, ...

  7. 修改 jquery.validate.js 支持非form标签

    尝试使用markdown来写一篇blog,啦啦啦 源代码传送门:github 在特殊情况下我们使用jquery.validate.js对用户输入的内容做验证的时候,表单并不是一定包含在form之中,有 ...

  8. 表单验证插件之jquery.validate.js

    提到表单验证的插件,第一个想到的就是jquery.validate.js,所以小生想在这里稍微详细地说一下这款插件的具体使用方法,便于理解,我直接附上整段demo的代码(没怎么调样式,主要是看js): ...

  9. 延迟加载外部js文件,延迟加载图片(jquery.lazyload.js和echo,js)

    js里一说到延迟加载,大都离不开两种情形,即外部Js文件的延迟加载,以及网页图片的延迟加载: 1.首先简单说一下js文件的3种延迟加载方式: (1)<script type="text ...

随机推荐

  1. 串口通信(C#实践)

    最近在做一个和智能硬件设备(数字焊接电源)通信的应用软件.和各设备之间通信使用的是串口或网络(Socket)的方式. 理论 串口通信,.NET 里提供了专门操作串口的类 System.IO.Ports ...

  2. 洛谷 P1930 亚瑟王的宫殿 Camelot

    传送门 题目大意:棋盘有骑士有王,让所有点跳到一个点,求所有棋子跳的步数和,和最小. 题解:bfs+枚举 王的人生: 1):自己走到聚集点 2):某个骑士来到王这里,两个棋子一起到聚集点 3):王走几 ...

  3. 2.2 web工程的目录结构

    [转] 一个最简单的Web应用的目录结构如下所示: Web应用的结构定义在Servlet的规范中,目前最新版本为3.1. 下载地址:https://jcp.org/aboutJava/communit ...

  4. SQL语句优化方法30例

    1. /*+ALL_ROWS*/ 表明对语句块选择基于开销的优化方法,并获得最佳吞吐量,使资源消耗最小化. 例如: SELECT /*+ALL+_ROWS*/ EMP_NO,EMP_NAM,DAT_I ...

  5. sublime 工具

    http://blog.csdn.net/admin_yi/article/details/53608965

  6. POJ2478(欧拉函数)

    Farey Sequence Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15242   Accepted: 6054 D ...

  7. mina2中IoHandler

    IoHandler 当我们通过IoSession执行相关操作的时候,如写数据,这些事件会触发Mina框架抽象的IoService实例,从而调用Mina框架底层的相关组件进行处理.这时,配置的IoHan ...

  8. C#简单操作XML

    类文件: class OperatorXML { /// <summary> /// 确定资源文件路径,Resource为自己创建的目录 /// </summary> priv ...

  9. C# 获取天气 JSON解析

    说明: winform获取中国天气的数据 中国天气返回的是JSON数据格式,这里做简单的解析. 用的http://www.weather.com.cn/data/sk/.html获取的天气.    [ ...

  10. mysql流程控制

    一 流程控制 delimiter // CREATE PROCEDURE proc_if () BEGIN declare i int default 0; if i = 1 THEN SELECT ...