一个自定义easyui组件属性的默认值的例子

$.fn.datagrid.defaults = $.extend({},$.fn.datagrid.defaults,{
	idField:'id',
	fitColumns:true,
	striped:true,
	loadMsg:'正在加载数据,请稍后……',
	onBeforeLoad:function(param){
		if(param.page){
			param['pageNum']=param.page;
			delete param.page;
		}
		if(param.rows){
			param['pageSize']=param.rows;
			delete param.rows;
		}
		var orders = [];
		if(param.sort){
			var order = param.order||"asc";
			orders.push({
				"property":param.sort,
				"sort":order
			});
			param["orders"]=JSON.stringify(orders);
			delete param.order;
			delete param.sort;
		}
	},
	loadFilter:function(data){
		if(data.success){
			return {total:data.total,rows:data.data};
		} else {
			var msg = "数据加载失败,请检查网络连接或联系管理人员";
			if(data.msg){
				msg += "["+data.msg+"]";
			}
			$.messager.alert('注意',msg);
			return {total:0,rows:[]};
		}
	}
});

 

你可能感兴趣的:(easyui)