jquery extend 多个扩展方法
$.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", "");
txtControl.combogrid({
panelWidth: ,
idField: 'Code',
textField: 'Name',
url: '/Common/EntityJsonList.ashx?_method=dict&dictType=' + dicType + "&tmp=" + Math.random() + '&queryTextFild=Name',
method: 'get',
delay: ,
columns: [[
{ field: 'Name', title: '名称', width: },
{ field: 'Code', title: '编码', width: }
]],
striped: true,
editable: true,
collapsible: false, //是否可折叠的
fit: true,
onLoadSuccess: function () {
window.setTimeout(function () {
$(".combo-arrow", option.valueControl.parent()).click();
}, );
},
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) {
//取得选中行的rowIndex
var index = txtControl.combogrid('grid').datagrid('getRowIndex', selected);
txtControl.val(selected.Name);
option.valueControl.val(selected.Code);
//向上移动到第一行为止
if (index > ) {
txtControl.combogrid('grid').datagrid('selectRow', index - );
}
} else {
var rows = txtControl.combogrid('grid').datagrid('getRows');
txtControl.combogrid('grid').datagrid('selectRow', rows.length - );
}
},
down: function () { //【向下键】押下处理
//取得选中行
var selected = txtControl.combogrid('grid').datagrid('getSelected');
if (selected) {
txtControl.val(selected.Name);
option.valueControl.val(selected.Code);
//取得选中行的rowIndex
var index = txtControl.combogrid('grid').datagrid('getRowIndex', selected);
//向下移动到当页最后一行为止
if (index < txtControl.combogrid('grid').datagrid('getData').rows.length - ) {
txtControl.combogrid('grid').datagrid('selectRow', index + );
}
} else {
txtControl.combogrid('grid').datagrid('selectRow', );
}
},
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;
var where = option.where;
//var keyword = option.keyword;
var pageSize = option.pageSize;
if (option.pageSize == null) {
pageSize = ;
}
var obj = valueControl;
if (panelHeight == null) {
panelHeight = ;
}
var url = '/common/EntityJsonList.ashx?entityType=' + option.entityType + '&_method=entity&tmp=' + Math.random() + '&queryTextFild=' + textField;
if (where) {
url += "&where=" + where;
}
if (panelWidth == null) {
panelWidth = ;
}
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", "");
textControl.combogrid({
panelWidth: panelWidth,
panelHeight: panelHeight,
idField: id,
textField: textField,
url: url,
method: 'get',
delay: ,
pagination: true, //是否分页
rownumbers: true, //序号
pageSize: pageSize, //每页显示的记录条数,默认为10
pageList: [pageSize, , , , , , , ], //可以设置每页记录条数的列表
columns: columns,
striped: true,
editable: true,
collapsible: false, //是否可折叠的
fit: true,
onLoadSuccess: function () {
window.setTimeout(function () {
$(".combo-arrow", option.valueControl.parent()).click();
}, );
},
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 = txtControlex
var index = combogrid('grid').datagrid('getRowIndex', selected);
valueControl.val(UTIL.getJsonByKey(selected, idFild));
textControl.val(UTIL.getJsonByKey(selected, textField));
//向上移动到第一行为止
if (index > ) {
textControl.combogrid('grid').datagrid('selectRow', index - );
}
} else {
var rows = textControl.combogrid('grid').datagrid('getRows');
textControl.combogrid('grid').datagrid('selectRow', rows.length - );
}
},
down: function () { //【向下键】押下处理
//取得选中行
var selected = textControl.combogrid('grid').datagrid('getSelected');
if (selected) {
valueControl.val(UTIL.getJsonByKey(selected, idFild));
textControl.val(UTIL.getJsonByKey(selected, textField));
//取得选中行的rowIndex
var index = textControl.combogrid('grid').datagrid('getRowIndex', selected);
//向下移动到当页最后一行为止
if (index < textControl.combogrid('grid').datagrid('getData').rows.length - ) {
textControl.combogrid('grid').datagrid('selectRow', index + );
}
} else {
textControl.combogrid('grid').datagrid('selectRow', );
}
},
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
});
}
});
}
});
jquery extend 多个扩展方法的更多相关文章
- jquery和zepto的扩展方法extend
jquery和zepto的扩展方法extend 总结下jQuery(3.1.1)和zepto(1.1.6)到底是如何来开放接口,使之可以进行扩展,两者都会有类型判断,本文使用简单的类型判断,暂不考虑兼 ...
- 在jQuery定义自己的扩展方法函数
今早复习昨天的练习jQuery的DropDownList联动功能,如果想看回<jQuery实现DropDownList(MVC)>http://www.cnblogs.com/insus/ ...
- jquery validate验证插件扩展方法(转)
/***************************************************************** jQuery Validate扩展验证方法 (linjq) *** ...
- jquery.extend方法
jquery.extend()用来扩展jquery中方法,实现插件. 1.jQuery.extend函数详细用法! 扩展jQuery静态方法. 1$.extend({ 2test:function() ...
- jQuery extend方法使用及实现
一.jQuery extend方法介绍 jQuery的API手册中,extend方法挂载在jQuery和jQuery.fn两个不同对象上方法,但在jQuery内部代码实现的是相同的,只是功能却不太一样 ...
- jQuery extend方法介绍
jQuery为开发插件提拱了两个方法,分别是: jQuery.fn.extend(object); jQuery.extend(object); jQuery.extend(object);为扩展jQ ...
- jquery扩展方法
jquery插件的开发包括两种:一种是类级别的插件开发,即给jquery添加新的全局函数,相当于给jquery类本身添加方法. jquery的全局函数就是属于jquery命名空间的函数,另一种是对象级 ...
- jQuery扩展方法笔记
一.方式列表: 1.jQuery.extend(Object); // jQuery 本身的扩展方法 2.jQuery.fn.extend(Object); // jQuery 所选对象扩展方法 二. ...
- 为Jquery类和Jquery对象扩展方法
转:https://www.cnblogs.com/keyi/p/6089901.html jQuery为开发插件提拱了两个方法,分别是: JavaScript代码 jQuery.fn.extend( ...
随机推荐
- 【spring源码学习】Spring的IOC容器之BeanPostProcessor接口学习
一:含义作用 ==>BeanPostProcessor接口是众多Spring提供给开发者的bean生命周期内自定义逻辑拓展接口中的一个 二:接口定义 package org.springfram ...
- #510. 「LibreOJ NOI Round #1」动态几何问题
题目: 题解: 几何部分,先证明一下 \(KX = \sqrt{a},YL = \sqrt{b}\) 设左侧的圆心为 \(O\) ,连接 \(OK\) ,我们有 \(OK = r\). 然后有 \(r ...
- Spring Aware接口---BeanNameAware BeanFactoryAware ApplicationContextAware
前言 对于应用程序来说,应该尽量减少对spring api的耦合程度,然后有时候为了运用spring提供的一些功能,有必要让bean了解spring容器对其管理的细节信息,如让bean知道在容器中是以 ...
- 缓存(Cache)管理 ---- 系列文章
利用Cache防止同一帐号重复登录 .net中Cache管理操作 系统缓存全解析 (下) 系统缓存全解析 (中) 系统缓存全解析 (上) 出处:http://www.cnblogs.com/luckd ...
- awk 内容
awk相关内容 #只要文件中的路径,不要文件名: [ ...
- nginx config的多个config配置
在我们的一台服务器上,一个nginx服务器下面可能跑着许多许多的项目; 那么就需要配置多个对应的配置 端口号 已经文件入库目录等等 那么项目多了以后,把这些项目都写到一个文件里 到后期难以查看与管理 ...
- ubuntu上安装Adminer
Apache 安装 $ sudo apt-get install apache2 php 安装 $ sudo apt-get install php7.0 $ sudo apt-get install ...
- WIN10运行软件,窗口不显示(移动到屏幕外无法复原)的解决办法 Lebal:bug10解决方案
双显示器切换回单显示器的时候,可能会遇到窗口移动到屏幕外不显示的情况 像这样虽然有缩略图但是点击无反应,并且平铺窗口也不管用,这个时候单击该窗口,Alt+space 执行最小化以及最大化操作即可复原
- 深入理解mysql索引
深入理解mysql索引 1 深入理解索引 1.1 索引基础理论知识: 1.2 B+树索引 1.3 哈希索引 1.4 理解B+树.哈希索引结构及区别: 1.5 理解常见索引的基本概念:主键索引.唯一索引 ...
- postgresql 9.5 pgpool 主从复制 以及错误解决
PostgreSQL+pgpool-II复制方案 这里不做功能的描述,只写搭建的过程和遇到的一些问题 1 系统 [root@mysqlhq ~]# cat /etc/redhat-release Ky ...