只要你传入相应的参数就能完成extjs表格的CRUD
|
003 |
*
@param {} saveButton |
|
008 |
*
@param {} assistFunc |
|
011 |
function commGridInsertAction(saveButton,gridObj,idName,treeObj,url,assistFunc){ |
|
012 |
if(saveButton
!= null &&
saveButton != undefined){ |
|
016 |
saveButton.on("click",function(){ |
|
017 |
var sd
= gridObj.getStore(); |
|
021 |
success: function(response,
opts){//成功操作 |
|
022 |
var obj
= Ext.decode(response.responseText)[0]; |
|
023 |
var Plant
= gridObj.getStore().recordType; |
|
024 |
var p
= new Plant(obj); |
|
025 |
gridObj.stopEditing(); |
|
027 |
gridObj.startEditing(0,
2); |
|
029 |
failure:function()
{//失败操作 |
|
030 |
Ext.Msg.alert("提示", "添加数据失败..."); |
|
038 |
*
@param {} deleteButton |
|
043 |
*
@param {} assistFunc |
|
046 |
function commGridDeleteAction(deleteButton,gridObj,idName,treeObj,url,params,assistFunc){ |
|
047 |
if(deleteButton
!= null &&
deleteButton != undefined){ |
|
051 |
deleteButton.on("click",function(b,e){ |
|
052 |
var sd
= gridObj.getStore(); |
|
053 |
var rs
= gridObj.getSelectionModel().getSelections(); |
|
054 |
var length
= rs.length; |
|
057 |
var dis_array
= new Array(); |
|
058 |
for (var i
= 0; i < length; i++) { |
|
060 |
ids_data
= rs[i].get(idName); |
|
062 |
ids_data
= ids_data + ","+rs[i].get(idName); |
|
064 |
dis_array.push(rs[i].get(idName)); |
|
067 |
para[idName]
= ids_data; |
|
071 |
success: function(response){//成功操作 |
|
074 |
for (var i
= 0; i < length; i++) { |
|
077 |
Ext.example.msg("提醒","您已经成功删除数据"); |
|
079 |
failure:function()
{//失败操作 |
|
080 |
Ext.Msg.alert("提示", "删除数据失败..."); |
|
084 |
Ext.Msg.alert("提示", "您还没有选择要删除的数据..."); |
|
091 |
*
@param {} listupdate |
|
095 |
*
@param {} assistFunc |
|
096 |
*
@param {} canUpdateFields |
|
099 |
functioncommGridListUpdateAction(listupdate,gridObj,treeObj,url,assistFunc,canUpdateFields){ |
|
100 |
if(listupdate
!= null &&
listupdate != undefined){ |
|
104 |
listupdate.on("click",function(){ |
|
105 |
var sd
= gridObj.getStore(); |
|
106 |
var objs
= sd.getModifiedRecords(); |
|
107 |
var objData
= new Array(); |
|
109 |
if(objs.length
== 0){ |
|
110 |
Ext.example.msg("提醒","没有要保存的数据"); |
|
113 |
for(var i
= 0 ; i<objs.length ;i++){ |
|
115 |
$.each(canUpdateFields,function(k,v){ |
|
116 |
model[k]
= objs[i].get(k); |
|
122 |
params
: {strData:JSON.stringify(objData)}, |
|
123 |
success: function(response,
opts){//成功操作 |
|
124 |
var i
= response.responseText; |
|
125 |
for(var j
= 0 ; j<objs.length ;j++){ //去掉修改的红色标记 |
|
129 |
Ext.example.msg("提醒","您已经成功修改
"+i+"
条数据"); |
|
131 |
failure:function()
{//失败操作 |
|
132 |
Ext.Msg.alert("提示", "保存数据失败..."); |
|
08 |
function userGridEventMonitor(gridObj,idName,treeObj){ |
|
10 |
var saveButton
= gridObj.getTopToolbar().findById("save-user"); |
|
11 |
new commGridInsertAction(saveButton,gridObj,idName,treeObj,"/dept/userAction.action?FunctionName=insertUser&checkNodeId="+gridObj.store.baseParams["checkNodeId"]); |
|
13 |
var deleteButton
= gridObj.getTopToolbar().findById("delete-user"); |
|
14 |
newcommGridDeleteAction(deleteButton,gridObj,idName,treeObj,"/dept/userAction.action?FunctionName=deleteUser&cascadeType=CASCADE", |
|
17 |
var listupdate
= gridObj.getTopToolbar().findById("listupdate-user"); |
|
18 |
new commGridListUpdateAction(listupdate,gridObj,treeObj, |
|
19 |
"/dept/userAction.action?FunctionName=listupdate", |
|
20 |
null,{"userId" : null, |
|
30 |
gridObj.on("celldblclick",function(g,rowIndex,columnIndex,e)
{ |
|
31 |
var sd
= g.getStore(); |
|
32 |
var cm
= g.getColumnModel(); |
|
33 |
var id
= cm.getDataIndex(columnIndex); |
|
35 |
var deptID
= sd.getAt(rowIndex).get("deptId"); |
|
36 |
var tree
= new sms.treeDicWin.treeDicWin({width:250,height:500, |
|
37 |
url:"/dept/deptAction.action?FunctionName=loadDept4Tree&showCheckbox=true&deptId=", |
|
38 |
text:"海顿是公司",idName:"userId",DicidName:"deptId",g:g,rowIndex:rowIndex,columnIndex:columnIndex}); |
|
40 |
}else if("photosAdd" ==
id){ |
|
41 |
var dialog
= new Ext.ux.UploadDialog.Dialog({ |
|
46 |
allow_close_on_upload: true, |
|
47 |
permitted_extensions:
['JPG','jpg','jpeg','JPEG','GIF','gif'], |
|
48 |
base_params:{className: "com.hd.department.model.user" } |
|
49 |
upload_autostart: false |
|
52 |
dialog.on("uploadsuccess", function(dialog,
filename, resp_data, record){ |