$.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 多个扩展方法的更多相关文章

  1. jquery和zepto的扩展方法extend

    jquery和zepto的扩展方法extend 总结下jQuery(3.1.1)和zepto(1.1.6)到底是如何来开放接口,使之可以进行扩展,两者都会有类型判断,本文使用简单的类型判断,暂不考虑兼 ...

  2. 在jQuery定义自己的扩展方法函数

    今早复习昨天的练习jQuery的DropDownList联动功能,如果想看回<jQuery实现DropDownList(MVC)>http://www.cnblogs.com/insus/ ...

  3. jquery validate验证插件扩展方法(转)

    /***************************************************************** jQuery Validate扩展验证方法 (linjq) *** ...

  4. jquery.extend方法

    jquery.extend()用来扩展jquery中方法,实现插件. 1.jQuery.extend函数详细用法! 扩展jQuery静态方法. 1$.extend({ 2test:function() ...

  5. jQuery extend方法使用及实现

    一.jQuery extend方法介绍 jQuery的API手册中,extend方法挂载在jQuery和jQuery.fn两个不同对象上方法,但在jQuery内部代码实现的是相同的,只是功能却不太一样 ...

  6. jQuery extend方法介绍

    jQuery为开发插件提拱了两个方法,分别是: jQuery.fn.extend(object); jQuery.extend(object); jQuery.extend(object);为扩展jQ ...

  7. jquery扩展方法

    jquery插件的开发包括两种:一种是类级别的插件开发,即给jquery添加新的全局函数,相当于给jquery类本身添加方法. jquery的全局函数就是属于jquery命名空间的函数,另一种是对象级 ...

  8. jQuery扩展方法笔记

    一.方式列表: 1.jQuery.extend(Object); // jQuery 本身的扩展方法 2.jQuery.fn.extend(Object); // jQuery 所选对象扩展方法 二. ...

  9. 为Jquery类和Jquery对象扩展方法

    转:https://www.cnblogs.com/keyi/p/6089901.html jQuery为开发插件提拱了两个方法,分别是: JavaScript代码 jQuery.fn.extend( ...

随机推荐

  1. fpga加法进位链实现过程中的一个特点

    altera fpga 用quartus综合后会出现加法进位链一正一反的情况,所谓一正一反指的是假设某一级输入为a,b,进位值为c,则该级进位链逻辑应该为cout=ab+ac+bc,但实际为 cout ...

  2. 【ftp】服务器的链接命令

    1. 连接ftp服务器 格式:ftp [hostname| ip-address] a)在Linux命令行下输入: ftp 192.168.1.1 b)服务器询问你用户名和密码,分别输入用户名和相应密 ...

  3. Ununto16.04版本Docker的安装2018年最新版本

    最近参照网上教程安装ubuntu的Docker怎么都不成功,我最后参照官方文档成功安装 https://docs.docker.com/engine/installation/linux/docker ...

  4. tensorflow dropout

    我们都知道dropout对于防止过拟合效果不错dropout一般用在全连接的部分,卷积部分不会用到dropout,输出曾也不会使用dropout,适用范围[输入,输出)1.tf.nn.dropout( ...

  5. SpringMvc入门四----rest风格Url

    知识点: REST风格URL简介 SpringMvc对rest风格的支持 @PathVariable 获取 Url 变量 SpringMvc对静态资源的处理 REST风格URL简介: 我们平时看到的s ...

  6. go语言学习杂记

    go语言在windows下下载安装 推荐在golang中国下载 http://www.golangtc.com/download 安装.... go环境变量与工作目录 根据约定GOPATH需要建立3个 ...

  7. POJ2142(扩展欧几里得)

    The Balance Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 5991   Accepted: 2605 Descr ...

  8. (转)Oracle存储过程中的事务

    本文转载自:http://www.cnblogs.com/linjiqin/archive/2011/04/18/2019990.html 1.事务用于确保数据的一致性,由一组相关的DML语句组成,该 ...

  9. Unity Shader入门教程(三)自制光照模型

    光照模型的概念目前还不明晰,因为笔者也是一个初学者,所以请小心对待笔者介绍的内容.笔者认为光照模型是规定光照算法的模型,比如说前面提到的Lambert光照模型,规定了材质表面的光线的表达式为 环境光+ ...

  10. AD9如何设置原点位置

    Edit --> Origin --> Set