2 Replies Latest reply on Mar 22, 2010 3:35 AM by Ling's

    How to check datagrid data is .txt file or .doc file..?

    Ling's Level 1

      Hi friends.,

       

                      my question is, using datagrid control datacolumn values to be check, the data comes only .txt,.doc and .ptf.

                         to binding different image with different files. How to check data ..?

       

       

      WIth Regards.,

      LinFlex-

        • 1. Re: How to check datagrid data is .txt file or .doc file..?
          Matt Le Fevre Level 4

          you'd need to store the file extension (.pdf , .doc , .txt) in a hidden field, and then run it through a function in your item renderer

           

           

          something like

           

          <mx:Script>
                  <![CDATA[
                      
                      [Embed(source="wordDocumentImage.png")]
                      [Bindable]
                      public var wordImage:Class;
                      
                      [Embed(source="txtDocumentImage.png")]
                      [Bindable]
                      public var txtImage:Class;
                      
                      [Embed(source="pngDocumentImage.png")]
                      [Bindable]
                      public var pngImage:Class;
                      
                      private function determineImage(value:String):Class
                      {
                          var returnImage:Class;
                          switch(value)
                          {
                              case ".png":
                              {
                                  returnImage = pngImage;
                                  break;
                              }
                              case ".doc":
                              {
                                  returnImage = wordImage;
                                  break;
                              }
                              case ".txt":
                              {
                                  returnImage = txtImage;
                                  break;
                              }
                          }
                          
                          return returnImage;
                      }
                      
                     
                  ]]>
              </mx:Script>
              
              <mx:Image source="{determineImage(data.fileExt)}"/>
          
          • 2. Re: How to check datagrid data is .txt file or .doc file..?
            Ling's Level 1

            Thank u Grizzz...

             

                            The values should return null.y means example(filename.doc) not checking .doc file.

            but i want only if the file is checking .doc or .txt ..ect.

            using string search is possible.. any idea...!

             

             

            With Regads

            LinFlex-