this.fnCompsEnable = function(oForm, bEnable, sExcept)
{
	var oComps = oForm.components;
	//if(bEnable) return;
	
	for (var i = 0; i < oComps.length; i++) {	
		if (oComps[i].readonly || sExcept.indexOf(oComps[i].name) > -1) {
			continue;
		}
		
		if (oComps[i] instanceof nexacro.Edit ||
			oComps[i] instanceof nexacro.MaskEdit ||
		    oComps[i] instanceof nexacro.Combo ||
			oComps[i] instanceof nexacro.Calendar) 
		{
			oComps[i].set_readonly(!bEnable);
			
			if (bEnable) continue;
			
			oComps[i].set_border("1px solid #9c9c9c");
			oComps[i].set_autoselect(true);
		}
		
		if (oComps[i] instanceof nexacro.CheckBox ||
		    oComps[i] instanceof nexacro.Radio) 
		{
			oComps[i].set_readonly(!bEnable);
		}
		
		if (oComps[i] instanceof nexacro.Button) 
		{
			oComps[i].set_enable(bEnable);
		}		
		
		if (oComps[i] instanceof nexacro.Div) 
		{
			this.fnCompsEnable(oComps[i].form, bEnable, sExcept);
		}
	}
}

var sExcept = "btnNext_01, btnDetail"; 
this.fnCompsEnable(this, false, sExcept); sExcept에 적힌 component name과 동일한 경우에는 bEnable의 반대값을 적용해주는 형태이다. 

무수히 많은 component enable을 여러 줄을 쓰지 않고 sExcept에 string 형태로 전달만 하면된다는 것이 장점이다.

 

 

 

'Web' 카테고리의 다른 글

Nexacro Dataset CRUD 정리  (0) 2020.06.18
Nexacro Div 정렬 Function  (0) 2020.06.18

+ Recent posts