jquery easyui使用心得--基于Spring和MyBatis

1.关于新增与编辑

this.add = function() {
		var selection = tree.tree('getSelected');
		var treeId = selection.id;
		var treeName = selection.text;
		addDialog = $.topDialog({
		    title:'新增',
		    iconCls:'icon-save',
		    href:addWinPath,
		    width : 800,     
			height : 400,
			resizable : true,
			modal : true,
			onClose:function(){
				addDialog = undefined;
				tempRec = undefined;
				editDialog = undefined;
			},
			onLoad:function(){	
				//给隐藏的区域ID赋值
				addDialog.find('[name="areaid"]').val(treeId);
				addDialog.find('[name="areaname"]').val(treeName);
		    },
			buttons:[{
				text:'保存',
				handler:function(){
					if(undefined == tempRec && null == tempRec){
						addDialog.find('.dialog-button .l-btn:first-child').linkbutton('disable');
						saveForminfo('new',addDialog);
					}else{
						editSave();
					}
				}
			},{
				text:'关闭',
				handler:function(){
					if(editDialog){
						$.topDialog('close',editDialog);
					}
					if(addDialog){
						$.topDialog('close',addDialog);
					}
				}
			}]
		});
	}
$.topDialog重要属性说明及注意事项:

  onClose:窗口关闭(右上角×)事件,在此事件中可以添加清除数据操作,防止多次弹出窗口时会出现因缓存等原因产生数据混淆;注:jQuery EasyUI的此默认方法是将窗口隐藏而非移除!

onLoad:窗口加载时渲染事件,在此事件中可以进行窗口数据初始化操作;编辑时的数据回填就是在此事件中editDialog.find('form').form('load', record);

2.Ajax使用

$.ajax({
			url: contextPath + '/mvc/xxx/xyyyy/zzzz/service/tree',
			data:{'id':node.id},
			success:function(nodes){
				if(nodes.length > 0){
					$('.add_button').linkbutton('disable');
				}else{
					$('.add_button').linkbutton('enable');
				}
				grid.datagrid('load', {areaid:node.id});
			}
		});
@RequestMapping("/xxx/xyyyy/zzzz")

/**
	 * 树节点查询
	 * 
	 * @param param
	 *            前台相关参数
	 * @return 当前页面记录
	 */
	@RequestMapping("/service/tree")
	@ResponseBody
	public List<TreeModel<T>> tree(String id, String root) {
		if (StringUtils.isNotBlank(root) && StringUtils.isBlank(id)) {
			// 包含当前节点
			return new TreeView(service.listTreeRoot(root)).convertTree();
		} else {
			// 子节点
			String isAble = "";//机构状态
			return new TreeView(service.listTreeById(id, isAble, null)).convertTree();
		}
	}


属性说明:

url:后台请求路径,该示例基于Spring和MyBatis框架,路径注意与后台RequestMapping对应;

data:参数集合;

success:回调函数



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值