2 Replies Latest reply on Sep 9, 2011 9:32 AM by jfb00

    Convert Object to string

    jfb00 Level 3

      Hi all,

      I have this sample:

      http://livedocs.adobe.com/flex/3/html/help.html?content=advdatagrid_04.html

       

      The function for style the column is:

      public function myStyleFunc(data:Object,             col:AdvancedDataGridColumn):Object           {              if (data["Artist"] == artistName)                 return {color:0xFF0000};                          // Return null if the Artist name does not match.              return null;                }

       

      How can I check if the three first letters of the Artist name is San?

      I try this:

      if (data["Artist"].toString().substring(0,3) == "San")

      But I am getting and error.

      Any ideas?

      Thanks

       

      Johnny

        • 1. Re: Convert Object to string
          Flex harUI Adobe Employee

          Post the error and stacktrace.  My guess is that you're not handling the

          case where data is null.

          • 2. Re: Convert Object to string
            jfb00 Level 3

            TypeError: Error #1010: A term is undefined and has no properties.

             

                at mx.controls::AdvancedDataGrid/applyUserStylesForItemRenderer()[C:\work\flex\dmv_automatio n\projects\datavisualisation\src\mx\controls\AdvancedDataGrid.as:1954]
                at mx.controls::AdvancedDataGrid/updateDisplayOfItemRenderer()[C:\work\flex\dmv_automation\p rojects\datavisualisation\src\mx\controls\AdvancedDataGrid.as:1899]
                at mx.controls.advancedDataGridClasses::AdvancedDataGridBase/drawItem()[C:\work\flex\dmv_aut omation\projects\datavisualisation\src\mx\controls\advancedDataGridClasses\AdvancedDataGri dBase.as:957]
                at mx.controls.advancedDataGridClasses::AdvancedDataGridBase/drawVisibleItem()[C:\work\flex\ dmv_automation\projects\datavisualisation\src\mx\controls\advancedDataGridClasses\Advanced DataGridBase.as:1009]
                at mx.controls::AdvancedDataGrid/drawVisibleItem()[C:\work\flex\dmv_automation\projects\data visualisation\src\mx\controls\AdvancedDataGrid.as:7251]
                at mx.controls.advancedDataGridClasses::AdvancedDataGridBase/createRow()[C:\work\flex\dmv_au tomation\projects\datavisualisation\src\mx\controls\advancedDataGridClasses\AdvancedDataGr idBase.as:1673]
                at mx.controls.advancedDataGridClasses::AdvancedDataGridBase/makeRowsAndColumns()[C:\work\fl ex\dmv_automation\projects\datavisualisation\src\mx\controls\advancedDataGridClasses\Advan cedDataGridBase.as:867]
                at mx.controls::AdvancedDataGridBaseEx/makeRowsAndColumns()[C:\work\flex\dmv_automation\proj ects\datavisualisation\src\mx\controls\AdvancedDataGridBaseEx.as:1923]
                at mx.controls::AdvancedDataGrid/makeRowsAndColumns()[C:\work\flex\dmv_automation\projects\d atavisualisation\src\mx\controls\AdvancedDataGrid.as:7172]
                at mx.controls.listClasses::AdvancedListBase/makeRowsAndColumnsWithExtraRows()[C:\work\flex\ dmv_automation\projects\datavisualisation\src\mx\controls\listClasses\AdvancedListBase.as: 1225]
                at mx.controls.listClasses::AdvancedListBase/updateDisplayList()[C:\work\flex\dmv_automation \projects\datavisualisation\src\mx\controls\listClasses\AdvancedListBase.as:3495]
                at mx.controls::AdvancedDataGridBaseEx/updateDisplayList()[C:\work\flex\dmv_automation\proje cts\datavisualisation\src\mx\controls\AdvancedDataGridBaseEx.as:1783]
                at mx.controls::AdvancedDataGrid/updateDisplayList()[C:\work\flex\dmv_automation\projects\da tavisualisation\src\mx\controls\AdvancedDataGrid.as:6010]
                at com.flexicious.lic::EadgBase/updateDisplayList()[C:\code\Flexicious\FlexiciousLicensing\s rc\com\flexicious\lic\EadgBase.as:80]
                at mx.controls.listClasses::AdvancedListBase/validateDisplayList()[C:\work\flex\dmv_automati on\projects\datavisualisation\src\mx\controls\listClasses\AdvancedListBase.as:3066]
                at mx.managers::LayoutManager/validateDisplayList()
                at mx.managers::LayoutManager/doPhasedInstantiation()
                at Function/http://adobe.com/AS3/2006/builtin::apply()
                at mx.core::UIComponent/callLaterDispatcher2()
                at mx.core::UIComponent/callLaterDispatcher()