ReactJS 컬럼계산 calculatedfield vs formatitem
추천0 비추천 0
페이지 정보
작성자 그리드맨 작성일 2023-12-12 17:23 조회 102회 댓글 0건제품 버전 : 최신
컨트롤 이름 : grid
본문
관련링크
제목 그대로
컬럼에 계산식을 적용할때 지금 두가지 방식으로 코딩 하고있는데요
아래 두가지 방식, 뭔차이인가요?
첫번째는
calculatedFields를 이용하는법
ex)
export function getCalculatedView() {
return new CollectionView(getData(), {
calculatedFields: {
PriceStr: "($.WholePrice * $.qty)",
Price: ($) => $.WholePrice * $.qty,
},
});
}
두번째는
formatItem을 이용하여 계산하는법
ex)
flex.formatItem.addHandler((s, e) => {
if (e.panel == s.cells) {
let r = s.rows[e.row],
c = s.columns[e.col],
item = s.rows[e.row].dataItem,
negative = false; // assume value is not negative
if (c.binding == "RestQty") {
let RestQty = item.UnSendQty - item.SendQty;
e.cell.textContent = Globalize.format(RestQty, c.format);
negative = RestQty < 0;
}
toggleClass(e.cell, "negative", negative);
}
});
댓글목록
등록된 댓글이 없습니다.