根据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 '[' + row['name'] + '] ' + 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
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);
- }
- }