! 제품 버전을 정확하게 입력해 주세요.
제품 버전이 정확하게 기재되어 있지 않은 경우,
최신 버전을 기준으로 안내 드리므로
더욱 빠르고 명확한 안내를 위해
제품 버전을 정확하게 입력해 주세요!

SourceBinding,FieldList 저장여부 > Q&A | 토론

본문 바로가기

ReactJS SourceBinding,FieldList 저장여부

페이지 정보

작성자 바밤바 작성일 2023-10-13 16:34 조회 217회 댓글 0건
제품 버전 : 16.1
컨트롤 이름 : SourceBinding,FieldList

본문

안녕하세요 제가 코드레벨에서 

1. fieldList를 동적으로 생성하고 동적으로 생성 

2. fieldList의 sourceBinding도 진행

3. fieldList에서 항목을 드래그해서 셀에 붙여넣으면 bindingPath가 입력됩니다.

4. fieldList Tab을 닫은후에 해당 bindingPath에 항목에 데이터를 입력하면 bindingPath가 입력된 곳에 value들이 모두 바뀝니다. 


이렇게 모든 과정을 실행후 저장 시점에 동적으로 생성된 fieldList와 binding될 데이터와 bindingPath 모두 저장하는 방법이 있나요??


더해서 fieldList와 binding될 데이터를 따로 뺄수있는 메소드도 존재하는지 궁금합니다.


아래는 Api 호출후 성공적으로 호출 했을때 실행되는 로직입니다. 

onSuccess(data) {
const jsonData = JSON.parse(data.data.data.jsondata);
const selectedKeys = JSON.parse(data.data.data.value);

const findNodes = (node: any, keys: any) => {
if (
keys.includes(node.key) ||
node.children.some((child: any) => findNodes(child, keys))
) {
return {
...node,
children: node.children
.map((child: any) => findNodes(child, keys))
.filter(Boolean),
};
}
return null;
};
// select Keys값을 기준으로 데이터를 추출.
const reconstructedData = jsonData
.map((node: any) => findNodes(node, selectedKeys))
.filter(Boolean);

// 최종적으로 가공된 데이터 result.
const result = processJsonData(reconstructedData, {
properties: {},
type: 'object',
});

// Sheet Binding Filed List 설정
designer?.setData('treeNodeFromJSON', JSON.stringify(result));

// Sheet Binding Data 가공
const transformData = (inputData: any) => {
const transformedData: any = {};

for (const key in inputData) {
// 각 키에 대한 데이터 가져오기
const keyData = inputData[key];

// 키 이름을 소문자로 변경하고 transformedData에 추가
const formattedKey = key.charAt(0).toUpperCase() + key.slice(1);
console.log(formattedKey);
transformedData[formattedKey] = processKeyData(keyData);
}

return transformedData;
};
// Sheet Binding 데이터 가공
const processKeyData = (keyData: any) => {
if (typeof keyData === 'object' && !Array.isArray(keyData)) {
const processedData: any = {};

if (keyData.properties) {
for (const subKey in keyData.properties) {
processedData[subKey] = processKeyData(
keyData.properties[subKey],
);
}
return processedData;
}

// Return an empty string if there are no properties.
return '';
}

// Return an empty string for the last value.
return '';
};

// sourceBinding 할 데이터
const bindData = transformData(result.properties);

// sourceBinding 할 데이터 설정
const source = new GC.Spread.Sheets.Bindings.CellBindingSource(
bindData,
);
const sheet = workbook?.getActiveSheet();
// sourceBinding 실행
sheet?.setDataSource(source);
},




  • 페이스북으로 공유
  • 트위터로  공유
  • 링크 복사
  • 카카오톡으로 보내기

댓글목록

등록된 댓글이 없습니다.

1 답변

ReactJS Re: SourceBinding,FieldList 저장여부

추천0 이 글을 추천하셨습니다 비추천0 채택채택

페이지 정보

작성자 GCK루카스 작성일 2023-10-17 10:03 댓글 0건

본문

안녕하세요 그레이프시티입니다.


디자이너 컴포넌트에서 생성한 것이 아닌, 동적으로 생성된 fieldList는 가져올 수 있는 메소드를 지원하지 않습니다.

동적으로 생성한 fieldList를 별도로 관리하여야 합니다.

bindingData는 getDataSource() 메소드를 이용하여 가져올 수 있습니다.

다만, bindingPath는 각 셀에 종속되기 때문에 bindingPath만 모아 저장하는 방법은 지원되지 않습니다.


[프리미엄 회원 전환 안내]
라이선스를 보유하고 계신다면, 누구나 추가 비용 없이 그레이프시티 포럼 프리미엄 회원이 될 수 있습니다.
프리미엄 회원으로 전환 시, 기술 문의에 대하여 우선 지원 받으실 수 있습니다.
아래 링크를 통해 프리미엄 회원 전환 방법 및 혜택 안내를 살펴보시길 바랍니다.


감사합니다.

그레이프시티 드림

댓글목록

등록된 댓글이 없습니다.

메시어스 홈페이지를 통해 제품에 대해서 더 자세히 알아 보세요!
홈페이지 바로가기
메시어스 홈페이지를 통해 제품에 대해서 더 자세히 알아 보세요!
홈페이지 바로가기
이메일 : sales-kor@mescius.com | 전화 : 1670-0583 | 경기도 과천시 과천대로 7길 33, 디테크타워 B동 1107호 메시어스(주) 대표자 : 허경명 | 사업자등록번호 : 123-84-00981 | 통신판매업신고번호 : 2013-경기안양-00331 ⓒ 2024 MESCIUS inc. All rights reserved.