프로그램/flex

Flex 에서 ItemRenderer 자세히 사용하기

mulderu 2009. 10. 24. 00:43
목록열기 전체보기 (1720)
[Flex] DataGrid itemRenderer 지정하는 방법 탐색 Flex / Programming

2009/10/22 08:57

복사 http://blog.naver.com/joycestudy/100091555619

 

방법1: itemRenderer에 mx 클래스 직접 지정

 

http://ejihong.egloos.com/9356499

- itemRenderer 설정하는 특이한 방법. mx 클래스를 직접 지정

<mx:DataGrid>
  <mx:columns>
   <mx:DataGridColumn headerText="Column 1" itemRenderer="mx.controls.Label" dataField="col1"/>
  </mx:columns>
</mx:DataGrid>

출처:[Flex] DataGrid 의 itemRenderer 의 Data Type

- itemRenderer의 data type은 IFactory

 

방법2: <mx:ItemRenderer> 태그 내에 <mx:Script> 넣기

 

http://vikinghammer.com/2009/02/25/flex-make-sure-to-call-super-in-item-renderer-override-methods/comment-page-1/

- <mx:ItemRenderer> 태그 내에 <mx:Script> 넣기

 

다음은, 정상 작동하는 코드.

<mx:itemRenderer>
    <mx:Component>
    <mx:Label>
        <mx:Script>
            <![CDATA[
                import mx.utils.StringUtil;
                public override function set data(item:Object):void {
                    super.data = item;
                    var str:String = item.firstman;
                    if (item.firstman == item.waiter) {
                        str = StringUtil.substitute('<b style="font-size: 13px;">{0}</b>', str);
                    }
                    htmlText = str;
                }
            ]]>
        </mx:Script>                           
    </mx:Label>
    </mx:Component>
</mx:itemRenderer>

- 실제로는, mxml 내에 이렇게 복잡한 코드를, 딱 한 번만 사용하기 위해 집어넣는 건 좋지 않다.

- 이렇게 해도 된다는 것, 정도…

- renderer 클래스로 빼내는 게 맞다.

 

http://flexdocs.kr/docs/flex2/langref/mxml/component.html

- 위와 같은 사용법을 설명.

- 변수값 참조도 가능함. DataGrid.dataProvider local_var app level var까지

 

 

보너스: 렌더러에서, app의 함수를 호출하는 방법

 

http://blogs.adobe.com/aharui/2007/03/thinking_about_item_renderers_1.html

Let's say you have a function in your main application file you want to reference. How do you reference it from within your itemRenderer component. Everything I try results in a 1069 error.

ReferenceError: Error #1069: Property myFunction not found on myApplication and there is no default value.

-------------------

Depends on how you wrote it. If it is an inline renderer (with mx:Component) then use outerDocument.myFunction().

If it is in a separate MXML file, use parentDocument.myFunction(),

and if it is an AS file, use owner.document.myFunction().

 

 

 

참고문서들

 

http://www.switchonthecode.com/tutorials/flex-datagrid-goodies-row-color-and-others

Flex DataGrid Goodies - Row Color and Others

- 아주 꼼꼼하게 잘 쓴 글.

- 조금 다른 예제. Row의 색깔을 바꾸기.

- 컬럼의 헤더 모양 바꾸기

 

http://devgeon.blogspot.com/2008/06/flex-3-advanced-datagrid.html

- Advanced DataGird 소개글. 빠른 시일내에 하나 만들어 봐야징~

  • 다중 Column 정렬 기능 ( multi column sorting interface )
  • 행 단위 Formatting ( cell-level formatting functions )
  • 계층적 보기 기능 ( tree view )
  • 행 단위 선택 기능 ( cell selection )
  • 열 수정 가능 ( custom rows )
  • 행 Groupping ( column grouping )
  • 합산 하기 및 Grid 출력하기 ( SummaryCollection and the PrintAdvancedDataGrid )
  •  

    [ FLEX3 ] itemRenderers ComboBox

    - itemRenderer 로 combo box 만들기

     

    http://blogs.adobe.com/aharui/2007/03/thinking_about_item_renderers_1.html

    - 렌더러에 관한 다양한 예제와 소스

    이 포스트를..

    덧글 쓰기 엮인글 쓰기

    확인 취소
    닫기