developer/java/javascript

그리드 셀의 내용이 긴 경우만 tooltiptext 나오게 하는 방법

모.서리 2012. 3. 5. 12:57

그리드에서 해당 Cell의 TEXT가 Cell의 폭 보다 긴 경우에만 TooltipText가 보여지도록 처리한 샘플 입니다.


ExtCommon의 getTextExtent 함수를 이용하여 처리 할 수 있습니다.


(2011.9.28 일자 extcommon에 해당 함수가 추가 되었습니다.)



var objExt = new ExtCommon();
function Grid00_onmousemove(obj:Grid, e:GridMouseEventInfo)
{
      if(e.row < 0) return;
 
      //componentID의 폰트 크기를 이용해 strText의 pixcel 단위 width, height 길이를 리턴한다.
      var CellTextLen = objExt.getTextExtent("Grid00", obj.getCellText(e.row, e.cell));
 
      if( CellTextLen[1] > obj.getRealColSize(e.cell) )
      {
            obj.tooltiptext = obj.getCellText(e.row,e.cell); //cell의 width 보다 클 경우만 tooltiptext 셋팅.
      } else {
            obj.tooltiptext = ""; //tooltiptext 초기화
      }
}