jeecg雙擊編輯的幾種格式

小鯉魚ya發表於2020-12-23
1.在datagrid的裡可以使用jeecg帶的雙擊編輯事件
2.新增雙擊編輯方法onDblClick="db_edit(rowIndex,rowData)"
//雙擊編輯行
function db_edit(rowIndex,rowData){
	var index= $('#airportCargoTrackingList').datagrid('getRowIndex', rowData);
	$('#airportCargoTrackingList').datagrid('beginEdit', index);
}
$('#airportCargoTrackingList')為datagrid定義的name名

3.新增了編輯方法並不能直接編輯,要給想要實現編輯的<t:dgCol />新增extendParams屬性,並設定要編輯的型別,如編輯文字型別:
<t:dgCol extendParams="editor:'text'" /> 
如編輯數值型別:
<t:dgCol extendParams="editor:'numberbox'" /> 
如編輯日期型別:
<t:dgCol extendParams="editor:'datebox'" /> 
如編輯繫結資料字典的型別:
<t:dgCol extendParams="editor:'combobox'" /> 

4.編輯後,要想獲取編輯後的資料,必須把編輯給關掉,否則獲取不到編輯後的資料
$('#airportCargoTrackingList').datagrid('endEdit', index);

總的程式碼

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="airportCargoTrackingList" checkbox="true" pagination="true" fitColumns="true" title="機場貨物跟蹤" onDblClick="db_edit(rowIndex,rowData)" actionUrl="airportCargoTrackingController.do?datagrid" idField="id" fit="true" queryMode="group">
   <t:dgCol title="id"  field="id"  hidden="true"  queryMode="group"  width="120"></t:dgCol>
   <t:dgCol title="公司名稱"  field="companyName"   extendParams="editor:'text'" queryMode="group"  width="120"></t:dgCol>
   <t:dgCol title="提單號"  field="ladingNumber"  queryMode="group"  extendParams="editor:'text'"  width="120"></t:dgCol>
   <t:dgCol title="件數"  field="number"  queryMode="group" extendParams="editor:'numberbox'"  width="120"></t:dgCol>
   <t:dgCol title="重量"  field="weight"  queryMode="group"  extendParams="editor:'text'"  width="120"></t:dgCol>
   <t:dgCol title="體積"  field="volume"  queryMode="group"  extendParams="editor:'text'"  width="120"></t:dgCol>
   <t:dgCol title="司機電話"  field="driverPhone" extendParams="editor:'text'"   queryMode="group"  width="120"></t:dgCol>
   <t:dgCol title="車牌"  field="licensePlate"  queryMode="group"  extendParams="editor:'text'" width="120"></t:dgCol>
   <t:dgCol title="顏色"  field="color"  queryMode="group" extendParams="editor:'text'"  width="120"></t:dgCol>
   <t:dgCol title="是否已讀"  field="isRead"  queryMode="single"  width="80"  dictionary="isRead" query="true"></t:dgCol>
   <t:dgCol title="執行時間"  field="executionTime"  formatter="yyyy-MM-dd" extendParams="editor:'datebox'" queryMode="group"  width="150"></t:dgCol>
   <t:dgCol title="狀態"  field="status"  queryMode="single"  width="80"  dictionary="trackingStatus" query="true"></t:dgCol>
   <t:dgCol title="目的點"  field="purpose"  queryMode="group" extendParams="editor:'text'"  width="120"></t:dgCol>
   <t:dgCol title="報關數"  field="declarationNum"  queryMode="group"  extendParams="editor:'text'"  width="120"></t:dgCol>
   <t:dgCol title="直單"  field="straightSingle"  queryMode="group" extendParams="editor:'combobox'"  dictionary="straightSingle" width="120"></t:dgCol>
   <t:dgCol title="主單數"  field="mainNum"  queryMode="group"  extendParams="editor:'numberbox'" width="120"></t:dgCol>
   <t:dgCol title="分單數"  field="singleNum"  queryMode="group"  extendParams="editor:'numberbox'" width="120"></t:dgCol>
   <t:dgCol title="建立日期"  field="createDate"  formatter="yyyy-MM-dd hh:mm:ss"  queryMode="group" autocomplete="off"   query="true"  width="120"></t:dgCol>
   <t:dgCol title="操作" field="opt" width="100"></t:dgCol>
   <t:dgDelOpt title="刪除" url="airportCargoTrackingController.do?doDel&id={id}" urlclass="ace_button"  urlfont="fa-trash-o"/>
   <t:dgToolBar title="錄入" icon="icon-add" url="airportCargoTrackingController.do?doAddAirport" funname="add"></t:dgToolBar>
   <t:dgToolBar title="編輯" icon="icon-edit" url="airportCargoTrackingController.do?goUpdate" funname="update"></t:dgToolBar>
   <t:dgToolBar title="批量刪除"  icon="icon-remove" url="airportCargoTrackingController.do?doBatchDel" funname="deleteALLSelect"></t:dgToolBar>
   <t:dgToolBar title="檢視" icon="icon-search" url="airportCargoTrackingController.do?goUpdate" funname="detail"></t:dgToolBar>
   <t:dgToolBar title="匯入" icon="icon-put" funname="ImportXls"></t:dgToolBar>
   <t:dgToolBar title="匯出" icon="icon-putout" funname="ExportXls"></t:dgToolBar>
   <t:dgToolBar title="模板下載" icon="icon-putout" funname="ExportXlsByT"></t:dgToolBar>
   <t:dgToolBar title="提交" icon="icon-putout" url="airportCargoTrackingController.do?doUpdateAirport" funname="submitData"></t:dgToolBar>
  </t:datagrid>
  </div>
 </div>
 <script src = "webpage/com/jeecg/airportCargoTracking/airportCargoTrackingList.js"></script>		
 <script type="text/javascript">
 $(document).ready(function(){
 });
 
 function add(title,url, id,width,height,isRestful) {
	 $.ajax({
			url : url,
			type : 'post',
			data : {
				type: "add",
			},
			cache : false,
			success : function(data) {
				var d = $.parseJSON(data);
				if (d.success) {
					reloadTable();
					$("#"+id).datagrid('unselectAll');
				}
			}
		});
 }
 
 function submitData(title,url, id,width,height,isRestful) {
	gridname=id;
 	var rowsData = $('#'+id).datagrid('getSelections'); 
 	if (!rowsData || rowsData.length==0) {
 		tip('請選擇專案');
 		return;
 	}
 	var index = 0;
 	$.dialog.setting.zIndex = getzIndex(true);
    	$.dialog.confirm('確定要提交嗎?', function(r) {
		   if (r) {
			    var rows = $('#airportCargoTrackingList').datagrid('getRows');
			 	for(var i = 0; i < rowsData.length; i++) {
			 		index = $('#airportCargoTrackingList').datagrid('getRowIndex', rowsData[i]);

				    var data2 = rows[index];
			 		$('#airportCargoTrackingList').datagrid('endEdit', index);
			 		var airport = JSON.stringify(data2) 
			 		$.ajax({
						url : url,
						type : 'post',
						data : {
							airportData: airport,
						},
						cache : false,
						success : function(data) {
							var d = $.parseJSON(data);
							if (d.success) {
								var msg = d.msg;
								tip(msg);
								reloadTable();
								$("#"+id).datagrid('unselectAll');
							}
						}
					});
			 	}
			}
		});
 }
 
//雙擊編輯行
function db_edit(rowIndex,rowData){
	var index= $('#airportCargoTrackingList').datagrid('getRowIndex', rowData);
	$('#airportCargoTrackingList').datagrid('beginEdit', index);
}   
 
//匯入
function ImportXls() {
	openuploadwin('Excel匯入', 'airportCargoTrackingController.do?upload', "airportCargoTrackingList");
}

//匯出
function ExportXls() {
	JeecgExcelExport("airportCargoTrackingController.do?exportXls","airportCargoTrackingList");
}

//模板下載
function ExportXlsByT() {
	JeecgExcelExport("airportCargoTrackingController.do?exportXlsByT","airportCargoTrackingList");
}

 </script>

相關文章