jquery extend 多个扩展方法
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了jquery extend 多个扩展方法,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含6371字,纯文字阅读大概需要10分钟。
内容图文
![jquery extend 多个扩展方法](/upload/InfoBanner/zyjiaocheng/1046/df203744abde484d869b4dd34fa9728a.jpg)
$.fn.extend({ SetDict: function (option) { var txtControl = $(this); if (!txtControl.hasClass("combo-text")) { // var width = txtControl.width(); //txtControl.addClass("combo"); } txtControl.click(function () { var obj = option.valueControl; var dicType = option.dicType; var isShow = txtControl.attr("isShow"); if (isShow == null || isShow == "") { txtControl.attr("isShow", "1"); txtControl.combogrid({ panelWidth: 250, idField: ‘Code‘, textField: ‘Name‘, url: ‘/Common/EntityJsonList.ashx?_method=dict&dictType=‘ + dicType + "&tmp=" + Math.random() + ‘&queryTextFild=Name‘, method: ‘get‘, delay: 1000, columns: [[ { field: ‘Name‘, title: ‘名称‘, width: 100 }, { field: ‘Code‘, title: ‘编码‘, width: 100 } ]], striped: true, editable: true, collapsible: false, //是否可折叠的 fit: true, onLoadSuccess: function () { window.setTimeout(function () { $(".combo-arrow", option.valueControl.parent()).click(); }, 100); }, onClickRow: function (index, row) { txtControl.val(row.Name); option.valueControl.val(row.Code); }, //自动大小keyHandler: { up: function () { //【向上键】押下处理 //取得选中行var selected = txtControl.combogrid(‘grid‘).datagrid(‘getSelected‘); if (selected) { //取得选中行的rowIndexvar index = txtControl.combogrid(‘grid‘).datagrid(‘getRowIndex‘, selected); txtControl.val(selected.Name); option.valueControl.val(selected.Code); //向上移动到第一行为止if (index > 0) { txtControl.combogrid(‘grid‘).datagrid(‘selectRow‘, index - 1); } } else { var rows = txtControl.combogrid(‘grid‘).datagrid(‘getRows‘); txtControl.combogrid(‘grid‘).datagrid(‘selectRow‘, rows.length - 1); } }, down: function () { //【向下键】押下处理 //取得选中行var selected = txtControl.combogrid(‘grid‘).datagrid(‘getSelected‘); if (selected) { txtControl.val(selected.Name); option.valueControl.val(selected.Code); //取得选中行的rowIndexvar index = txtControl.combogrid(‘grid‘).datagrid(‘getRowIndex‘, selected); //向下移动到当页最后一行为止if (index < txtControl.combogrid(‘grid‘).datagrid(‘getData‘).rows.length - 1) { txtControl.combogrid(‘grid‘).datagrid(‘selectRow‘, index + 1); } } else { txtControl.combogrid(‘grid‘).datagrid(‘selectRow‘, 0); } }, enter: function () { //【回车键】押下处理 txtControl.combogrid(‘hidePanel‘); var selected = txtControl.combogrid(‘grid‘).datagrid(‘getSelected‘); if (selected) { txtControl.val(selected.Name); option.valueControl.val(selected.Code); } }, query: function (keyword) { //【动态搜索】处理 //设置查询参数var queryParams = txtControl.combogrid("grid").datagrid(‘options‘).queryParams; queryParams.keyword = keyword; txtControl.combogrid("grid").datagrid(‘options‘).queryParams = queryParams; //重新加载 txtControl.combogrid("grid").datagrid("reload"); txtControl.combogrid("setValue", keyword); } }, mode: ‘remote‘, fitColumns: true }); } }); } }); $.fn.extend({ SetCombo: function (option) {///<reference path="../Common/JGridJson.cs" />var entityType = option.entityType; var textField = option.textField; var textControl = $(this); var panelWidth = option.panelWidth; var idFild = option.idFild; var valueControl = option.valueControl; var panelHeight = option.panelHeight; var columns = option.columns; varwhere = option.where; //var keyword = option.keyword;var pageSize = option.pageSize; if (option.pageSize == null) { pageSize = 10; } var obj = valueControl; if (panelHeight == null) { panelHeight = 300; } var url = ‘/common/EntityJsonList.ashx?entityType=‘ + option.entityType + ‘&_method=entity&tmp=‘ + Math.random() + ‘&queryTextFild=‘ + textField; if (where) { url += "&where=" + where; } if (panelWidth == null) { panelWidth = 500; } if (valueControl.val() != "") { url += "&defaultValue=" + escape(valueControl.val()); } var id = ‘Id‘; if (idFild != null) { id = idFild; } url += "&idFild=" + id; textControl.click(function () { var a = textControl.attr("isShow"); if (a == "" || a == null) { textControl.attr("isShow", "1"); textControl.combogrid({ panelWidth: panelWidth, panelHeight: panelHeight, idField: id, textField: textField, url: url, method: ‘get‘, delay: 1000, pagination: true, //是否分页 rownumbers: true, //序号 pageSize: pageSize, //每页显示的记录条数,默认为10 pageList: [pageSize, 10, 20, 30, 40, 50, 100, 200], //可以设置每页记录条数的列表 columns: columns, striped: true, editable: true, collapsible: false, //是否可折叠的 fit: true, onLoadSuccess: function () { window.setTimeout(function () { $(".combo-arrow", option.valueControl.parent()).click(); }, 100); }, onClickRow: function (index, row) { valueControl.val(UTIL.getJsonByKey(row, idFild)); textControl.val(UTIL.getJsonByKey(row, textField)); }, //自keyHandler: { up: function () { //【向上键】押下处理 //取得选中行var selected = textControl.combogrid(‘grid‘).datagrid(‘getSelected‘); if (selected) { //取得选中行的rowIndex = txtControlexvar index = combogrid(‘grid‘).datagrid(‘getRowIndex‘, selected); valueControl.val(UTIL.getJsonByKey(selected, idFild)); textControl.val(UTIL.getJsonByKey(selected, textField)); //向上移动到第一行为止if (index > 0) { textControl.combogrid(‘grid‘).datagrid(‘selectRow‘, index - 1); } } else { var rows = textControl.combogrid(‘grid‘).datagrid(‘getRows‘); textControl.combogrid(‘grid‘).datagrid(‘selectRow‘, rows.length - 1); } }, down: function () { //【向下键】押下处理 //取得选中行var selected = textControl.combogrid(‘grid‘).datagrid(‘getSelected‘); if (selected) { valueControl.val(UTIL.getJsonByKey(selected, idFild)); textControl.val(UTIL.getJsonByKey(selected, textField)); //取得选中行的rowIndexvar index = textControl.combogrid(‘grid‘).datagrid(‘getRowIndex‘, selected); //向下移动到当页最后一行为止if (index < textControl.combogrid(‘grid‘).datagrid(‘getData‘).rows.length - 1) { textControl.combogrid(‘grid‘).datagrid(‘selectRow‘, index + 1); } } else { textControl.combogrid(‘grid‘).datagrid(‘selectRow‘, 0); } }, enter: function () { //【回车键】押下处理 textControl.combogrid(‘hidePanel‘); var selected = textControl.combogrid(‘grid‘).datagrid(‘getSelected‘); if (selected) { valueControl.val(UTIL.getJsonByKey(selected, idFild)); textControl.val(UTIL.getJsonByKey(selected, textField)); } }, query: function (keyword) { //【动态搜索】处理 //设置查询参数var queryParams = textControl.combogrid("grid").datagrid(‘options‘).queryParams; queryParams.keyword = keyword; textControl.combogrid("grid").datagrid(‘options‘).queryParams = queryParams; //重新加载 textControl.combogrid("grid").datagrid("reload"); textControl.combogrid("setValue", keyword); } }, mode: ‘remote‘, fitColumns: true }); } }); } });
原文:http://www.cnblogs.com/kexb/p/5172404.html
内容总结
以上是互联网集市为您收集整理的jquery extend 多个扩展方法全部内容,希望文章能够帮你解决jquery extend 多个扩展方法所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。