当前位置:网站首页>EasyUi常用代码
EasyUi常用代码
2022-08-04 19:44:00 【zcy_wxy】
根据text设置combobox的值
function setValueByText(textArray,comboName,textName,valueName){
let dataArray=$("#"+comboName).combobox('getData');
if (textArray.length>1){
let values=[];
let map = new Map();
for (const data of dataArray) {
map.set(data[textName],data[valueName]);
}
for (const tx of textArray) {
values.push(map.get(tx));
}
$("#"+comboName).combobox('setValues',values);
return;
}
for (const data of dataArray) {
if(textArray[0]==data[textName]){
$("#"+comboName).combobox('setValue',data[valueName]);
break;
}
}
}
通过值数组来设置Combobox值
function setValueByValueArray(valueArray,comboName){
if (valueArray.length>1){
$("#"+comboName).combobox('setValues',valueArray);
return;
}
$("#"+comboName).combobox('setValue',valueArray[0]);
}
常用DatagridFormater
formatter:function(value,row,index){
return $("#xxx").combobox("setValue",value).combobox("getText");
}
formatter:function(value,row,index){
if (value){
return $("#xxx").combobox("setValues",value.split(',')).combobox("getText");
}
}
Combobox初始化,带输入过滤功能
$('#'+id).combobox({
url: xxx,
valueField: 'code',
textField: 'name',
panelHeight: '150',
width: 150,
height: 25,
multiple: true,
formatter: function(row){
return '<span style="font-weight:bold;color:blue;">[' + row['name'] + ']</span> ' + row['name'];
},
loadFilter: function (data) {
return data;
},
filter: function(q, row){
return row['code'].toLowerCase().indexOf(q.toLowerCase()) >= 0 || row['name'].indexOf(q) >=0;
},
onShowPanel : function(){
var count = $(this).combobox('getData').length;
if(count > 10){
$(this).combobox('panel').height(180);
}else{
$(this).combobox('panel').height("auto");
}
}
});
多列下拉列表combogrid
$('#xx').combogrid({
url: xxx,
idField: 'code',
textField: 'name',
panelHeight: '200',
width: 200,
height: 25,
multiple: true,
columns:[[
{field : 'ck', checkbox : true},
{field : 'code', title : 'xx', width : 80 ,hidden:true},
{field : 'name', title : 'xx', width : 80}
]],
loadFilter: function (data) {
return data;
}
});
常用功能-根据String数组创建combobox的Item
function createComboboxItem(stringsList) {
if (stringsList==null||stringsList.length==0)return [];
var result=new Array();
var text;
for (var i=0;i<stringsList.length;i++){
text=stringsList[i];
result.push({text:text,value:text});
}
return result;
}
combobox禁用或启用
function frozenPart(frozen,id){
if (frozen){
$("#"+id).combobox('disable');
}else{
$("#"+id).combobox('enable');
}
}
combobox选择第一项
function selectCombobox(tarComboboxName){
var comboboxName='#'+tarComboboxName;
var data = $(comboboxName).combobox('getData');
if (data!=null&&data.length > 0) {
$(comboboxName).combobox('select', data[0].code);
}
}
边栏推荐
- 如何手动下载并安装 Visual Studio Code 的 SAP Fiori tools - Extension Pack
- "WAIC 2022 · hackers marathon" two ants wealth competition invited you to fight!
- v-model的使用
- c sqlite ... ...
- 如果是测试 axi dma抓数的话 看这里
- getBoundingClientRect
- 完善的交叉编译环境记录 peta 生成的shell 脚本
- Query the published version records of the APP Store
- Video Object Detection
- [Latest Information] 2 new regions will announce the registration time for the soft exam in the second half of 2022
猜你喜欢
JS new一个构造器发生了什么?从零手写一个new方法
Video Object Detection
电脑一键重装系统内存完整性无法打开怎么办
基于HDF的LED驱动程序开发(2)
Dragoma(DMA)元宇宙系统开发
Use "green computing" technology to promote sustainable development of computing power
Quantitative trading robot system development
元国度链游系统开发
哈佛架构 VS 冯·诺依曼架构
ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators
随机推荐
Defaced Fingerprint Recovery and Identification
Kubernetes之list-watch机制
MySQL远程备份策略举例
如何使用 jMeter Parallel Controller - 并行控制器以及一些常犯的错误
Client Side Cache 和 Server Side Cache 的区别
Spark提交参数说明和常见优化
面试官:JVM运行时数据区包含哪几部分?作用是啥?
正畸MIA微种植体支抗技术中国10周年交流会在沈举办
Orthodontic MIA micro-implant anchorage technology China 10th anniversary exchange meeting was held in Shenyang
2022年国内手机满意度榜单:华为稳坐国产品牌第一
成品升级程序
PostgreSQL的 SPI_接口函数
存储资源盘活系统助力新基建
正畸MIA微种植体支抗技术中国10周年交流会在沈举办
5G NR 笔记记录
【有奖征文】秋招特训,打造你的专属产品体验
How to promote the implementation of rural revitalization
如何手动下载并安装 Visual Studio Code 的 SAP Fiori tools - Extension Pack
红外图像滤波
getBoundingClientRect