easyui queryParam 자동화

3238 단어 easyui
/**
 * @author LiuQing
 */
function Check() {
};
Check.messageBox = function messageBox(title,bodyText,type) {
	if (!type || type == "") {
		type = "info"
	}
	 $.messager.alert(title,bodyText,type);
};
/**
 *  
 * @param gridId String
 * @param formId String
 */
Check.datagridQuery = function datagridQuery(gridId,formId) {
	$("#"+gridId).datagrid({"queryParams":Check.loadFormData($("#" + formId))});
};
/**
 * 
 * @param form  
 * @returns {Object}
 */
Check.loadFormData = function loadFormData(form) {
	var dataArray = $(form).serializeArray();
	var obj = new Object();
	$.each(dataArray,function(i,field){
		obj[field.name] = field.value;
	});
	return obj;
};

Check.setWidthWindow = function setWidthWindow(obj) {
	$(obj).css({"width":$(window).width()});
};

Check.setHeightWindow = function setHeightWindow(obj) {
	$(obj).css({"height":$(window).height()});
};
/**
 *  weight
 * @param obj
 */
Check.setWh = function setWh(obj) {
	$(obj).css({"height":$(window).height(),"width":$(window).width()});
};

/**
 *  
 */
Check.rootPath = function getRootPath(){
    var curWwwPath=window.document.location.href;
    var pathName=window.document.location.pathname;
    var pos=curWwwPath.indexOf(pathName);
    var localhostPaht=curWwwPath.substring(0,pos);
    var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
    return(localhostPaht+projectName);
};

/**
 * @param DataGrid datagrid easyuiObject
 * @param Integer itemSize  
 */
Check.validateSelectItems = function isSelectItemNum(datagrid,itemSize) {
	if (itemSize <= 0) {
		return true;
	}
	var rows = $(datagrid).datagrid('getSelections');
	var rowLength = rows.length;
	if (rowLength <= 0) {
		$.messager.show({
            title:' ',
            msg:' [' + itemSize+ '] ',
            timeout:5000,
            showType:'slide'
        });
		return false;
	}
	else if (rowLength != itemSize) {
		$.messager.show({
            title:' ',
            msg:' [' + rowLength + '] , [' + itemSize + '] ',
            timeout:5000,
            showType:'slide'
        });
		return false;
	}
	return true;
};
/**
 *  
 */
$.extend({easyui:{}});
$.extend($.easyui,{
	datagridQuery:function(gridId,formId){
		Check.datagridQuery(gridId,formId)
	},
	path:function(){
		return Check.rootPath();
	},
	messageBox:function(title,bodyText,type){
		Check.messageBox(title,bodyText,type);
	},
	validateSelectItems:function(datagrid,itemSize){
		return Check.validateSelectItems(datagrid,itemSize);
	}
	
});

 

좋은 웹페이지 즐겨찾기