2 Replies Latest reply on Mar 22, 2010 10:33 PM by Flex harUI

    How to use substring and lastindexof() in datagrid..?

    Ling's Level 1



        To check the datagrid datacolumn file is .txt , .doc or .pdf. to binding different images using sub string ,lastindexof or match(patterns).

      Any one help this code....




      <mx:DataGridColumn width="20" resizable="false"  >
                                                                  public var wordImage:Class;
                                                                  public var txtImage:Class;
                                                                  public var pdfImage:Class;
                                                                  private function determineImage(str:String):Class
                                                                      var returnImage:Class
                                                                      //var txtdoc:String = str;
                                                                      var txtdoc:Number = str.lastIndexOf( '.doc' );
                                                                      if ( txtdoc != -1 )
                                                                          return wordImage;
                                                                      else( txtdoc == -1 )
                                                                          return txtImage;
                                                                      return returnImage;


                                                           <mx:HBox >
                                                          <mx:Image source="{determineImage(data.document_long_name)}"    toolTip="{data.document_long_name}                                                        Notes"  buttonMode="true" />


      With Regards.,