工作实例:
增加脚本:
function tmpl_append() {
var p = parent.$('').dialog({
title : '新增模版',
href : '<%=request.getContextPath() %>/jsp/import/tmplOperate.jsp',
width : 400,
height : 300,
modal: true,
buttons : [ {
text : '保存',
iconCls:'icon-save',
handler : function() {
var f = p.find('form');
f.form('submit', {
url : '<%=request.getContextPath() %>/tmplConfigInfoAction!save.action',
method : 'post',
//enctype : "multipart/form-data",
onSubmit: function(){
if(!f.find('#tmplName').validatebox('isValid')){
f.find('#tmplName').focus();
return false;
}
$.messager.progress();
},
success : function(json) {
$.messager.progress('close');
var json = eval('(' + json + ')');
if (json.success) {
tmplTable.treegrid('reload');
p.dialog('close');
$.messager.show({
msg : json.msg,
title : '提示'
});
}else{
$.messager.show({
msg : json.msg,
title : '提示'
});
}
}
});
}
},{
text: '取消',
iconCls:'icon-no',
handler: function(){
p.dialog('close');
}
} ],
onOpen:function(){
fixIE6SelectZindexIssue(true);
},
onLoad:function(){
},
onClose:function(){
p.dialog('destroy');
fixIE6SelectZindexIssue(false);
}
});
}
62
62
1
function tmpl_append() {
2
var p = parent.$('').dialog({
3
title : '新增模版',
4
href : '<%=request.getContextPath() %>/jsp/import/tmplOperate.jsp',
5
width : 400,
6
height : 300,
7
modal: true,
8
buttons : [ {
9
text : '保存',
10
iconCls:'icon-save',
11
handler : function() {
12
var f = p.find('form');
13
f.form('submit', {
14
url : '<%=request.getContextPath() %>/tmplConfigInfoAction!save.action',
15
method : 'post',
16
//enctype : "multipart/form-data",
17
onSubmit: function(){
18
if(!f.find('#tmplName').validatebox('isValid')){
19
f.find('#tmplName').focus();
20
return false;
21
}
22
$.messager.progress();
23
},
24
success : function(json) {
25
$.messager.progress('close');
26
var json = eval('(' + json + ')');
27
if (json.success) {
28
tmplTable.treegrid('reload');
29
p.dialog('close');
30
31
$.messager.show({
32
msg : json.msg,
33
title : '提示'
34
});
35
}else{
36
$.messager.show({
37
msg : json.msg,
38
title : '提示'
39
});
40
}
41
}
42
});
43
}
44
},{
45
text: '取消',
46
iconCls:'icon-no',
47
handler: function(){
48
p.dialog('close');
49
}
50
} ],
51
onOpen:function(){
52
fixIE6SelectZindexIssue(true);
53
},
54
onLoad:function(){
55
56
},
57
onClose:function(){
58
p.dialog('destroy');
59
fixIE6SelectZindexIssue(false);
60
}
61
});
62
}
修改:
function tmpl_edit() {
var rows = $("#tmplTable").treegrid('getSelections');
var p = parent.$('').dialog({
title : '修改模版',
href : '<%=request.getContextPath() %>/jsp/import/tmplOperate.jsp',
width : 400,
height : 300,
modal: true,
buttons : [ {
text : '保存',
iconCls:'icon-save',
handler : function() {
var f = p.find('form');
f.form('submit', {
url : '<%=request.getContextPath() %>/tmplConfigInfoAction!save.action?chooseTmplId='+rows[0].tmplId,
method : 'post',
//enctype : "multipart/form-data",
onSubmit: function(){
if(!f.find('#tmplName').validatebox('isValid')){
f.find('#tmplName').focus();
return false;
}
$.messager.progress();
},
success : function(json) {
$.messager.progress('close');
var json = eval('(' + json + ')');
if (json.success) {
tmplTable.treegrid('reload');
p.dialog('close');
$.messager.show({
msg : json.msg,
title : '提示'
});
}else{
$.messager.show({
msg : json.msg,
title : '提示'
});
}
}
});
}
},{
text: '取消',
iconCls:'icon-no',
handler: function(){
p.dialog('close');
}
} ],
onLoad:function(){
var f = p.find('form');
f.find('input[name=tmplName]').val(rows[0].tmplName);
f.find('input[name=tablePrefix]').val(rows[0].tablePrefix);
f.find('input[name=upTmplId]').val(rows[0].upTmplId);
},
onOpen:function(){
fixIE6SelectZindexIssue(true);
},
onClose:function(){
p.dialog('destroy');
fixIE6SelectZindexIssue(false);
}
});
}
66
66
1
function tmpl_edit() {
2
var rows = $("#tmplTable").treegrid('getSelections');
3
var p = parent.$('').dialog({
4
title : '修改模版',
5
href : '<%=request.getContextPath() %>/jsp/import/tmplOperate.jsp',
6
width : 400,
7
height : 300,
8
modal: true,
9
buttons : [ {
10
text : '保存',
11
iconCls:'icon-save',
12
handler : function() {
13
var f = p.find('form');
14
f.form('submit', {
15
url : '<%=request.getContextPath() %>/tmplConfigInfoAction!save.action?chooseTmplId='+rows[0].tmplId,
16
method : 'post',
17
//enctype : "multipart/form-data",
18
onSubmit: function(){
19
if(!f.find('#tmplName').validatebox('isValid')){
20
f.find('#tmplName').focus();
21
return false;
22
}
23
$.messager.progress();
24
},
25
success : function(json) {
26
$.messager.progress('close');
27
var json = eval('(' + json + ')');
28
if (json.success) {
29
tmplTable.treegrid('reload');
30
p.dialog('close');
31
32
$.messager.show({
33
msg : json.msg,
34
title : '提示'
35
});
36
}else{
37
$.messager.show({
38
msg : json.msg,
39
title : '提示'
40
});
41
}
42
}
43
});
44
}
45
},{
46
text: '取消',
47
iconCls:'icon-no',
48
handler: function(){
49
p.dialog('close');
50
}
51
} ],
52
onLoad:function(){
53
var f = p.find('form');
54
f.find('input[name=tmplName]').val(rows[0].tmplName);
55
f.find('input[name=tablePrefix]').val(rows[0].tablePrefix);
56
f.find('input[name=upTmplId]').val(rows[0].upTmplId);
57
},
58
onOpen:function(){
59
fixIE6SelectZindexIssue(true);
60
},
61
onClose:function(){
62
p.dialog('destroy');
63
fixIE6SelectZindexIssue(false);
64
}
65
});
66
}
删除:
function tmpl_del(){
var rows = tmplTable.treegrid('getSelections');
if(rows==0){
$.messager.alert('提示', '请选择要删除的记录!', 'error');
return;
}else{
$.messager.confirm('请确认','您确定要删除选中的记录吗?',function(b){
if(b){
var childrenRows = tmplTable.treegrid('getChildren',rows[0].tmplId);
if(childrenRows.length>0){
$.messager.confirm('请确认','您要删除的记录包含子模版,如果删除会将子模版也删掉,确定要删除吗?',function(a){
if(a){
var list = new Array();
for(var i=0;i/tmplConfigInfoAction!del.action',
{tmplIds:list.join()}, //传参到后台删除
function(data){
$.messager.progress('close');
if (data && data.success) {
$.messager.show({
msg : data.msg,
title : '提示'
});
tmplTable.treegrid('reload');
} else {
$.messager.show({
msg : data?data.msg:"删除失败!",
title : '提示'
});
tmplTable.treegrid('unselectAll');
}
},'json'
);
}
});
//
}else{
var list = new Array();
for(var i=0;i/tmplConfigInfoAction!del.action',
{tmplIds:list.join()}, //传参到后台删除
function(data){
$.messager.progress('close');
if (data && data.success) {
$.messager.show({
msg : data.msg,
title : '提示'
});
tmplTable.treegrid('reload');
} else {
$.messager.show({
msg : data?data.msg:"删除失败!",
title : '提示'
});
tmplTable.treegrid('unselectAll');
}
},'json'
);
}// else
}
});
}
}
73
73
1
function tmpl_del(){
2
var rows = tmplTable.treegrid('getSelections');
3
if(rows==0){
4
$.messager.alert('提示', '请选择要删除的记录!', 'error');
5
return;
6
}else{
7
$.messager.confirm('请确认','您确定要删除选中的记录吗?',function(b){
8
if(b){
9
var childrenRows = tmplTable.treegrid('getChildren',rows[0].tmplId);
10
if(childrenRows.length>0){
11
$.messager.confirm('请确认','您要删除的记录包含子模版,如果删除会将子模版也删掉,确定要删除吗?',function(a){
12
if(a){
13
var list = new Array();
14
for(var i=0;i<rows.length;i++){
15
list.push(rows[i].tmplId);
16
}
17
$.messager.progress();
18
$.post('<%=request.getContextPath()%>/tmplConfigInfoAction!del.action',
19
{tmplIds:list.join()}, //传参到后台删除
20
function(data){
21
$.messager.progress('close');
22
if (data && data.success) {
23
$.messager.show({
24
msg : data.msg,
25
title : '提示'
26
});
27
tmplTable.treegrid('reload');
28
29
} else {
30
$.messager.show({
31
msg : data?data.msg:"删除失败!",
32
title : '提示'
33
});
34
tmplTable.treegrid('unselectAll');
35
}
36
},'json'
37
);
38
}
39
});
40
41
//
42
}else{
43
44
var list = new Array();
45
for(var i=0;i<rows.length;i++){
46
list.push(rows[i].tmplId);
47
}
48
$.messager.progress();
49
$.post('<%=request.getContextPath()%>/tmplConfigInfoAction!del.action',
50
{tmplIds:list.join()}, //传参到后台删除
51
function(data){
52
$.messager.progress('close');
53
if (data && data.success) {
54
$.messager.show({
55
msg : data.msg,
56
title : '提示'
57
});
58
tmplTable.treegrid('reload');
59
60
} else {
61
$.messager.show({
62
msg : data?data.msg:"删除失败!",
63
title : '提示'
64
});
65
tmplTable.treegrid('unselectAll');
66
}
67
},'json'
68
);
69
}// else
70
}
71
});
72
}
73
}
HTML
tmplConfig.jsp
54
54
1
<body>
2
<div style="padding: 5px;overflow: hidden;">
3
4
<form method="post" id="addTmplDialog">
5
<input type="hidden" id="copyOldId" name="copyOldId">
6
<input type="hidden" name="oldParentId">
7
<table style="width: 100%" style="border-collapse:collapse; table-layout:fixed" >
8
<tr height="30px">
9
<td style="width: 150px;text-align: center;" >模版名称:td>
10
<td>
11
<s:if test="#request.currentTmplId=='' || #request.currentTmplId==null">
12
<input id="tmplName" name="tmplName" class="easyui-validatebox" data-options="required:false,validType:'tmplName[2,10]'" style="width: 155px;" />
13
s:if>
14
<s:if test="#request.currentTmplId!=''&request.currentTmplId!=null">
15
<input id="tmplName" name="tmplName" class="easyui-validatebox" data-options="required:false,validType:'tmplName[2,10,${requestScope.currentTmplId }]'" style="width: 155px;" />
16
s:if>
17
td>
18
tr>
19
<tr id="treeShow" height="30px">
20
<td style="width: 150px;text-align: center;">上级模版:td>
21
<td>
22
<input id="upTmplIdComboTree" name="upTmplId" style="width: 155px;" />
23
td>
24
25
tr>
26
<tr height="30px">
27
<td style="width: 150px;text-align: center;" >导入数据表名前缀:td>
28
<td>
29
30
<s:if test="#request.currentTmplId=='' || #request.currentTmplId==null">
31
<input id="tablePrefix" name="tablePrefix" class="easyui-validatebox" data-options="required:false,validType:'tablePrefix[2,10]'" style="width: 155px;" />
32
s:if>
33
<s:if test="#request.currentTmplId!=''&request.currentTmplId!=null">
34
<input id="tablePrefix" name="tablePrefix" class="easyui-validatebox" data-options="required:false,validType:'tablePrefix[2,10,${requestScope.currentTmplId }]'" style="width: 155px;" />
35
s:if>
36
37
td>
38
39
tr>
40
41
table>
42
如果确定是父菜单,可以随便填写表名前缀,不影响使用。
43
form>
44
div>
45
46
<script type="text/javascript">
47
var upTmplTree;
48
$(document).ready(function(){
49
upTmplTree = $('#upTmplIdComboTree');
50
$("tr:even").css("background","rgb(245,245,245)"); //奇数行的样式
51
$("tr:odd").css("background","white"); //偶数行的样式
52
});
53
script>
54
body>