0 Replies Latest reply on Dec 27, 2006 9:06 AM by YuliyaR

    ClassFactory and click property issue

    YuliyaR
      Hi,

      I'm trying to create an Image as an itemRendered for a DataGridColumn and assign a click event for the image. The code is:

      var tItemRenderer:ClassFactory = new ClassFactory(Image);
      tItemRenderer.properties = {source: "../images/icon_delete_03_3.jpg"};
      tItemRenderer.properties = {click: confirmClick};
      gridCol.itemRenderer = tItemRenderer;


      When running the code get the error below:

      ReferenceError: Error #1056: Cannot create property click on mx.controls.Image.
      at mx.core::ClassFactory/newInstance()
      at mx.controls.dataGridClasses::DataGridBase/ http://www.adobe.com/2006/flex/mx/internal::columnItemRenderer()
      at mx.controls::DataGrid/::getMeasuringRenderer()
      at mx.controls::DataGrid/mx.controls:DataGrid::commitProperties()
      at mx.core::UIComponent/validateProperties()
      at mx.managers::LayoutManager/::validateProperties()
      at mx.managers::LayoutManager/::doPhasedInstantiation()
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at mx.core::UIComponent/::callLaterDispatcher2()
      at mx.core::UIComponent/::callLaterDispatcher()


      Why am I receiving this error when Image does have a click property. The following code works as expected:
      ...
      <mx:DataGridColumn id="grid4col1" width="14" editable="false">
      <mx:itemRenderer>
      <mx:Component>
      <mx:Image click="parentDocument.confirmClick();" source="@Embed('../images/icon_delete_03_3.jpg')" />
      </mx:Component>
      </mx:itemRenderer>
      </mx:DataGridColumn>
      ...

      I've also tried
      tItemRenderer.properties = {click: this.confirmClick};
      tItemRenderer.properties = {click: parentDocument.confirmClick};

      instead of tItemRenderer.properties = {click: confirmClick};


      Thanks,
      Yuliya