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( ...
随机推荐
- vs2015 c++ _findnext 报错
定位 _findnext(hFile,&fileinfo) 报错. 错误 :0x00007FFC70CB0B2D (ntdll.dll)处(位于 Cutton_Dlg.exe 中)引发的异常: ...
- bzoj 2946 [Poi2000]公共串——后缀自动机
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2946 对每个串都建一个后缀自动机,然后 dfs 其中一个自动机,记录同步的话在别的自动机上走 ...
- 在actionbar中加入item的方法
首先在menu文件夹中创建post.xml <?xml version="1.0" encoding="utf-8"?> <menu xmln ...
- curl -I 说明
curl -I 查看header头信息
- 摆花 (DP动态规划)
2012_p3 摆花 (flower.cpp/c/pas) 时间限制: 1 Sec 内存限制: 128 MB提交: 17 解决: 10[提交][状态][讨论版][命题人:外部导入] 题目描述 3. ...
- Git 学习小问题记录
最近一直使用Git在管理代码,但是的确不规范,今天开始恶补Git常用命令.实际今天的任务是需要从master牵出一条branch.心想着这个简单只补一下创建分支以及merge的这边的命令就可以了,于是 ...
- 《PHP对象、模式与实践》之高级特性
高级特性包括:1.静态方法和属性(通过类而不是对象来访问数据和功能)2.抽象类和接口(设计,实现分离)3.错误处理(异常)4.Final类和方法(限制继承)5.拦截器(自动委托)6.析构方法(对象销毁 ...
- js中的class
js中的class 类写法 class SuperClass { constructor(option) { this.a = option; } fn() { console.log(this.b) ...
- chart左侧
左侧单位 Chart1.Axes.Left.Minimum := ; Chart1.Axes.Left.Maximum := Series1.YValues.MaxValue * ; Chart1.A ...
- easyui之datagrid之formatter(后台传递常量自动转换值)
1,datagrid之formatter formatter格式化函数有三个参数: value:字段值(一般为后台传递给前台的值): row:当前行数据: index:当前行索引. return值是显 ...