jquery dropdownlist.js
$.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 dropdownlist.js的更多相关文章
- jquery.validate.js表单验证
一.用前必备官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ API: http://jquery.bassist ...
- MVC - 11(下)jquery.tmpl.js +ajax分页
继续 mvc-11(上).dto:http://www.cnblogs.com/tangge/p/3840060.html jquery.tmpl.js 下载:http://pan.baidu.com ...
- 【转】jquery.validate.js表单验证
一.用前必备官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ API: http://jquery.bassist ...
- [转]jquery.validate.js表单验证
原文地址:https://www.cnblogs.com/si-shaohua/p/3780321.html 一.用前必备官方网站:http://bassistance.de/jquery-plugi ...
- jquery和Js的区别和基础操作
jqery的语法和js的语法一样,算是把js升级了一下,这两种语法可以一起使用,只不过是用jqery更加方便 一个页面想要使用jqery的话,先要引入一下jqery包,jqery包从网上下一个就可以, ...
- jQuery.template.js 简单使用
之前看了一篇文章<我们为什么要尝试前后端分离>,深有同感,并有了下面的评论: 我最近也和前端同事在讨论这个问题,比如有时候前端写好页面给后端了,然后后端把这些页面拆分成很多的 views, ...
- 修改 jquery.validate.js 支持非form标签
尝试使用markdown来写一篇blog,啦啦啦 源代码传送门:github 在特殊情况下我们使用jquery.validate.js对用户输入的内容做验证的时候,表单并不是一定包含在form之中,有 ...
- 表单验证插件之jquery.validate.js
提到表单验证的插件,第一个想到的就是jquery.validate.js,所以小生想在这里稍微详细地说一下这款插件的具体使用方法,便于理解,我直接附上整段demo的代码(没怎么调样式,主要是看js): ...
- 延迟加载外部js文件,延迟加载图片(jquery.lazyload.js和echo,js)
js里一说到延迟加载,大都离不开两种情形,即外部Js文件的延迟加载,以及网页图片的延迟加载: 1.首先简单说一下js文件的3种延迟加载方式: (1)<script type="text ...
随机推荐
- niosii 改变软核之后重新编译方法
操作系统:Win7 64 bit 开发环境:Quartus II 12.0 (64-Bit) + Nios II 12.0 Software Build Tools for Eclipse 使用Qu ...
- jenkins 重置密码
说明 最近在折腾jenkins,配置用户权限时点错了,选择了安全矩阵后没有添加用户,就保存配置了,然后就报错了,提示没有Overall/Read权限.还有另外一个问题,用户的密码忘记了怎么办? 一 ...
- 手把手教你在Eclipse中使用CVS Branch功能
Brach 的作用: 开发新版本的人员就基于 main trunk 工作,而 fix bug 的人员就基于 branch 工作. 一旦在 branch上将 Release_1_0的 bug修复了,我们 ...
- leetcode 21.Merge Two Sorted Lists ,java
题目: Merge two sorted linked lists and return it as a new list. The new list should be made by splici ...
- 不让activity显示UI的办法
直接把 //setContentView(R.layout.activity_welcome); 注释掉就是了
- python开发模块基础:异常处理&hashlib&logging&configparser
一,异常处理 # 异常处理代码 try: f = open('file', 'w') except ValueError: print('请输入一个数字') except Exception as e ...
- [置顶]
sscanf() - 从一个字符串中读进与指定格式相符的数据
在做一道九度上机题时,突然发现sscanf()函数非常有用,就顺便从网上搜集资料整理一下. sscanf() 的作用:从一个字符串中读进与指定格式相符的数据. 原型: int sscanf (cons ...
- linux输入子系统概念介绍
在此文章之前,我们讲解的都是简单的字符驱动,涉及的内容有字符驱动的框架.自动创建设备节点.linux中断.poll机制.异步通知.同步互斥.非阻塞.定时器去抖动. 上一节文章链接:http://blo ...
- StringBuilder与StringBuffer的区别
相信大家看到过很多比较String和StringBuffer区别的文章,也明白这两者的区别,然而自从Java 5.0发布以后,我们的比较列表上将多出一个对象了,这就是StringBuilder类.St ...
- 6.solr学习速成之multicore查询
查询关联多个core 再新建一个core 向每个core添加索引,修改 final static String SOLR_URL = "http://localhost:8080/solr/ ...