Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Money data type

    Is there a money data type? If not, any plans to add it in the future?

    Thanks

    #2
    Hi Mark
    There is no Money Data type at present, and it's not a feature that we have any immediate plans to implement. It should be relatively straightforward to apply the formatting etc behavior you need for a currency field using underlying 'float' type data.

    However if it's a feature you'd like to see, please feel free to drop a request for it into the Wishlist forum.

    Thanks
    Isomorphic Software

    Comment


      #3
      Hmm. I'm trying to do this with a ListGrid but I'm not sure what's the best way to do it. I could use transformResponse to just hunt down and format every currency value, but that would not be very efficient. Is there any way to override formatting for individual fields when they display in the grid, such that I can check field.type and format it properly if type=="currency"?

      Comment


        #4
        Take a look at the SimpleType subsystem. We'd recommend probably representing the value in integer or decimal and supplying formatters.

        Comment


          #5
          For the general enlightenment of the community, the following works well:

          Code:
          isc.SimpleType.create({
              name:"currency",inheritsFrom:"float",
              normalDisplayFormatter: function(value) {
                  return this.shortDisplayFormatter(value);
              },
              shortDisplayFormatter: function(value) {
                  // US currency formatter from http://javascript.internet.com/forms/currency-format.html
              
                  if (value==undefined)
                      return value;
                  else {
                      value = value.toString().replace(/\$|\,/g,'');
                      if(isNaN(value))
                      value = "0";
                      sign = (value == (value = Math.abs(value)));
                      value = Math.floor(value*100+0.50000000001);
                      cents = value%100;
                      value = Math.floor(value/100).toString();
                      if(cents<10)
                      cents = "0" + cents;
                      for (var i = 0; i < Math.floor((value.length-(1+i))/3); i++)
                      value = value.substring(0,value.length-(4*i+3))+','+
                      value.substring(value.length-(4*i+3));
                      
                      return (((sign)?'':'-') + '$' + value + '.' + cents);
                  }
              }
          });
          Of course, for non-US currencies you would have to use a different formatter. Also, with this code the short display value is the same as the long display value (so, for instance, you might want to leave out the cents in a short display format, and for that you'd need to modify the formatter).

          Thanks Isomorphic!

          Comment


            #6
            Nice, thanks for posting that.

            Comment


              #7
              Indian Currency Format

              Hi Isomorhic and ledifini,

              Can you please provide code for indian currency format..or is there any isomorphic attributes by default for non us currency

              example:
              in US :123,456,778,

              IN:12,34,56,778


              How Can i get the above format?

              Please Reply Asap.

              Thanks in advance

              Comment

              Working...
              X