5 Replies Latest reply on Nov 12, 2011 9:26 AM by nikos101

    Implicit coercion DefaultGridItemRenderer to an unrelated type IFactory

    nikos101 Level 2

      why can't  I do this:

       

      I get an error:

      Implicit coercion of a value of type spark.skins.spark:DefaultGridItemRenderer to an unrelated type

      mx.core:IFactory.

       

      public class Numeric_SparkGridColumn extends GridColumn
      {
          public function Numeric_SparkGridColumn(columnName:String=null)
          {
              super(columnName);
              this.sortCompareFunction = compareFunctionNumeric;
              this.dataTipFunction = fullDateInfo;
              labelFunction = formatBritishDateDG;
              var renderer:DefaultGridItemRenderer = new DefaultGridItemRenderer;
              renderer.setStyle("textAlign",'right');
             
              this.itemRenderer = renderer;
             
          }

       

       

      I'm trying to do something like this in as :

       

      <s:GridColumn headerText="Attachments" dataField="NoAttachments" width="70">
      <s:itemRenderer>
      <fx:Component>
      <s:GridItemRenderer>
        • 1. Re: Implicit coercion DefaultGridItemRenderer to an unrelated type IFactory
          Claudiu Ursica Level 4

          Is more like:

           

          var renderer:ClassFactory = new ClassFactory(DefaultGridItemRenderer);

          this.itemRenderer = renderer;

          C

          • 2. Re: Implicit coercion DefaultGridItemRenderer to an unrelated type IFactory
            nikos101 Level 2

            but how to do this:

            var renderer:ClassFactory = new ClassFactory(DefaultGridItemRenderer);

                       renderer.setStyle("textAlign",'right');


            • 3. Re: Implicit coercion DefaultGridItemRenderer to an unrelated type IFactory
              Flex harUI Adobe Employee

              Class StyleableClassFactory extends ClassFactory

              {

                  override public function newInstance():Object

                  {

                      var obj:Object = super.newInstance();

                      obj.setStyle(“textAlign”, “right”);

                  }

               

              • 4. Re: Implicit coercion DefaultGridItemRenderer to an unrelated type IFactory
                nikos101 Level 2

                yuck I guess I'll stick to non as itemrenderers

                • 5. Re: Implicit coercion DefaultGridItemRenderer to an unrelated type IFactory
                  nikos101 Level 2

                  I done it this way, shame cause I wanted an all in one as component like the far below code

                   

                   


                  <s:GridColumn dataField="compensation"  width="100" sortCompareFunction="{Sorters.sparkCompareFunctionNumeric}">





                  <s:itemRenderer>






                  <fx:Component>







                  <s:GridItemRenderer>








                  <s:Label id="labelDisplay" maxDisplayedLines="1" styleName="nameColumn" width="100%" textAlign="right" height="100%" verticalAlign="middle" paddingRight="8"/>







                  </s:GridItemRenderer>






                  </fx:Component>





                  </s:itemRenderer>




                  </s:GridColumn>

                   

                  package views.extendedComponents

                  {

                   

                      import mx.formatters.DateFormatter;

                      import mx.utils.ObjectUtil;

                   

                      import spark.components.gridClasses.GridColumn;

                   

                      public class DateSortDefault_SparkGridColumn extends GridColumn

                      {

                          public function DateSortDefault_SparkGridColumn(columnName:String=null)

                          {

                              super(columnName);

                              this.sortCompareFunction = CompareFuncDate;

                              this.dataTipFunction = fullDateInfo;

                              labelFunction = formatBritishDateDG;

                          }

                   

                   

                          private function formatBritishDateDG(item:Object, column:GridColumn):String {

                              var dateFormatter:DateFormatter = new DateFormatter();

                              dateFormatter.formatString = 'DD/MM/YYYY';

                              var columnDataField:String = column.dataField;

                              return dateFormatter.format(item[columnDataField]);

                          }

                   

                   

                          private function fullDateInfo(item:Object, column:GridColumn):String{

                              var dateFormatter:DateFormatter = new DateFormatter();

                              dateFormatter.formatString = 'EEE DD/MM/YYYY at L:NN A';

                              var columnDataField:String = column.dataField;

                              return dateFormatter.format(item[columnDataField]);

                   

                   

                   

                          }

                   

                   

                          public static function CompareFuncDate(itemA:Object, itemB:Object,column:GridColumn):int

                          {

                              var columnDataField:String = column.dataField;

                              var dateA:Date=new Date(Date.parse(itemA[columnDataField]));

                              var dateB:Date=new Date(Date.parse(itemB[columnDataField]));

                              return ObjectUtil.dateCompare(dateB, dateA);

                          }

                   

                      }

                  }