1 Reply Latest reply on Oct 11, 2011 4:08 AM by pjoshi_infocepts

    questions about how to format file size

    madhooper Level 1

      I'm attempting to format the file size on a filesystemdatagrid column.

       

      private function formatFileSize(numSize:Number, data:object):String {

                                              var strReturn:String;

                                              numSize = Number(numSize / 1000);

                                              strReturn = String(numSize.toFixed(1) + " KB");

                                              if (numSize > 1000) {

                                                        numSize = numSize / 1000;

                                                        strReturn = String(numSize.toFixed(1) + " MB");

                                                        if (numSize > 1000) {

                                                                  numSize = numSize / 1000;

                                                                  strReturn = String(numSize.toFixed(1) + " GB");

                                                        }

                                              }

                                              return strReturn;

                                    }

       

       

      my strReturn is NAN.

      when i debug it's sure look like a number to me.

       

      Can anyone help or suggest another way of showing the file size in a readable format?

       

      Thanks

        • 1. Re: questions about how to format file size
          pjoshi_infocepts

          Hi,

           

          In FileSystemDataGrid we can choose "size" column display as either "bytes" or "kilobytes".

           

          Try out this code -

           

          <mx:ApplicationControlBar dock="true">
               <mx:Label text="Select size display mode:" />
               <mx:ComboBox id="sizeDisplayMode" dataProvider="[bytes,kilobytes]" />
          </mx:ApplicationControlBar>

           

          <mx:FileSystemDataGrid id="fsdg"
               sizeDisplayMode="{sizeDisplayMode.selectedItem}"
               directory="{File.userDirectory}"
               horizontalScrollPolicy="off" />

           

          Hope this help you.

           

          Thanks and Best regards,

          -------------------------------------------------------------------------

          Pallavi Joshi | pjoshi@infocepts.com | www.infocepts.com

          -------------------------------------------------------------------------

          1 person found this helpful