jeecg双击编辑并实现双击选择

  1. 将要变成下拉选择的字段添加extendParams="editor:‘text’"
<t:dgCol title="公司名称"  field="companyName"  extendParams="editor:'text'" queryMode="group"  width="120">t:dgCol>
  1. 使用select2实现,要导入select2的css和js

<link rel="stylesheet" href="plug-in/select2/css/select2.min.css">
<script type="text/javascript" src="plug-in/select2/js/select2.full.min.js">script>
  1. js方法
//双击编辑行
function db_edit(rowIndex,rowData){
     
	var index= $('#airportCargoTrackingList').datagrid('getRowIndex', rowData);
	$('#airportCargoTrackingList').datagrid('beginEdit', index);
	arrIndex.push(index)
	
	//通过此方法可以拿到选择器
	var ed = $("#airportCargoTrackingList").datagrid('getEditor', {
     index:index,field:"companyName"});
	var companyId = $("#airportCargoTrackingList").datagrid('getEditor', {
     index:index,field:"companyId"});
	var select2Data = new Array();
	$.ajax({
     
		url : "airportCargoTrackingController.do?getCustomer",
		type:'GET',
		dataType:'JSON',
		delay: 250,
		cache: true,
		success: function(data){
     
			for(var i = 0; i < data.length; i++){
     
				var select2Obj = {
     };
				
				select2Obj.id = data[i].id;
				select2Obj.text = data[i].cus_company;
				select2Data.push(select2Obj);
			}
			//通过ed.target选择此标签赋值
			$(ed.target).select2({
     
				data: select2Data,
				placeholder:'请选择公司',//默认文字提示
			    language: "zh-CN",//汉化
			    allowClear: true//允许清空
			});
			
			$(ed.target).val(rowData.companyId).trigger('change')
			$(ed.target).change(function(){
      	  				 
				 //委托客户中文名称修改					 
				 var temp = $(this).select2("data"); 
				 var name = temp[0].text;
				 var id = temp[0].id;
				 $(companyId.target).val(id)
				 $(ed.target).val(name);	
			 });

		}
	});
}

你可能感兴趣的:(Java,java,js)