728x90
반응형
SMALL

좌측에는 기본 고정된 표를 미리 만들어 둔 후 우측으로 늘어나는 구조

 

    var objDsData = this.dsMainG;           // 그리드에 바인딩된 데이터셋
    var objGrid = this.grdMain;            // 그리드 컴포넌트
	
    // --- 그리드 재구성 준비 ---
    objGrid.set_enableevent(false); // 이벤트 발생 일시 정지 (성능 향상)
    objGrid.set_autofittype("none"); // 자동 너비 조절 기능 일시 해제 (포맷 변경 중 오류 방지)
    
    
    var nNewColIndex = 5; // 새로 추가할 컬럼의 인덱스는 기존 컬럼 개수 다음 번호

	var sNewColumnXml = ''; // id는 데이터셋 컬럼과 일치
	var sNewHeadCellXml = ''; // col은 숫자 인덱스
	var sNewBodyCellXml = ''; // col은 숫자, colid는 문자열
	var sNewSummCellXml = ''; // col은 숫자, colid는 문자열
    
    // 3. 새로 추가할 <Column> 태그와 <Cell> 태그 문자열 생성
	// (현재 버전의 XML 구조에 맞춰 <Column> 사용)
	for(var i=0; i<this.dsMain2.getRowCount(); i++){
		sNewColumnXml += '<Column size="100"/>'; 
		sNewHeadCellXml += '<Cell col="' + (nNewColIndex+i) + '" text="타이틀'+i+'" />'
		sNewBodyCellXml += '<Cell col="' + (nNewColIndex+i) + '" text="bind:MyData" textAlign="center" color="#666666"/>';
		sNewSummCellXml += '<Cell col="' + (nNewColIndex+i) + '" text="totalCnt" textAlign="center"  color="#666666"/>';
	
	}
	
			
	// 4. 기존 XML에 새로운 <Column>과 <Cell> 삽입
	// <Columns> 태그 닫기 바로 앞에 새로운 <Column> 추가
	sCurrentFormat = sCurrentFormat.replace(/<\/Columns>/, sNewColumnXml + '</Columns>'); // <Columns>로 변경되었음을 가정

	// <Band id="head"> 태그 닫기 바로 앞에 새로운 <Cell> 추가
	sCurrentFormat = sCurrentFormat.replace(/(<Band id="head"[\s\S]*?)<\/Band>/, '$1' + sNewHeadCellXml + '</Band>');

	// <Band id="body"> 태그 닫기 바로 앞에 새로운 <Cell> 추가
	sCurrentFormat = sCurrentFormat.replace(/(<Band id="body"[\s\S]*?)<\/Band>/, '$1' + sNewBodyCellXml + '</Band>');
	
	// <Band id="summary"> 태그 닫기 바로 앞에 새로운 <Cell> 추가
	sCurrentFormat = sCurrentFormat.replace(/(<Band id="summary"[\s\S]*?)<\/Band>/, '$1' + sNewSummCellXml + '</Band>');

	// 5. 변경된 포맷 XML을 그리드에 적용
	objGrid.set_formats(sCurrentFormat); // **여기서 올바른 XML 문자열을 적용**
	
    objGrid.set_enableevent(true);  // 이벤트 다시 활성화
728x90
반응형
LIST

+ Recent posts