[CLOSED] Razor - negitive number formats

  1. #1

    [CLOSED] Razor - negitive number formats

    Hi Guys

    I had a good look around on extjs and ext.net but don't see this one. Is there a list of all the formats and is one of them for (0,000.00) which would represent a negative number. This is an accountancy style format.

    Regards
    Last edited by Daniil; Feb 19, 2013 at 3:41 AM. Reason: [CLOSED]
  2. #2
    Hello!

    Sorry, I don't quite understand what exactly is your problem with format, can you provide more information. To format value to accountancy style you can use Ext.util.Format.currency and it works with negative values too: http://docs.sencha.com/ext-js/4-1/#!...ethod-currency
  3. #3
    So... data from database would be say -1.23 the renderer should then turn that into (1.23)
  4. #4
    Yes, you can customize Ext.util.Format to do this.

    If you have more questions about this I think it will be easier if you will provide some example and we can give you the best solution.
  5. #5
    I have checked out the docs and searched the forums etc and can't see any syntax or example of formatting negative numbers like this , can you give me a tested example of ext.util.format representing a negative number as (1234.00) E.g. database gives -1234.00 and ext.util.format gives the result of (1234.00)

    I really don't think I need to start reposting my MVC example with a number column added for half a line of code.
  6. #6
    Sorry, I misunderstood your requirement.

    Unfortunately, there is no number format to do what you want but you can use the following overriding to remove negative sign:

     Ext.override(Ext.form.NumberField, {
    	setValue: function(v) {
    		if (v){
    			v = Ext.util.Format.number(v, '0,000.00');
    			v.replace(/^[+-]/, '');
    		}
    		
    		return Ext.form.NumberField.superclass.setValue.call(this, v);
    	}
    });
  7. #7
    Thanks! i'll give it a try and let you know. Do you know if handling this type of formating will be included in the future?
  8. #8
    Quote Originally Posted by OriCoder View Post
    Do you know if handling this type of formating will be included in the future?
    I doubt. But it can be easily implemented with a common Column with a custom Renderer.

Similar Threads

  1. [CLOSED] Managing Date Formats
    By RCM in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 04, 2012, 3:48 PM
  2. [CLOSED] [Razor] HyperLink Text in Razor
    By UnifyEducation in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 20, 2012, 12:16 PM
  3. [CLOSED] [Razor] Setup Auto load panel in razor
    By UnifyEducation in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 27, 2012, 10:54 AM
  4. Replies: 0
    Last Post: Aug 30, 2011, 2:48 PM
  5. util formats for Ext.util.Format.fileSize
    By fatihunal in forum 1.x Help
    Replies: 2
    Last Post: May 21, 2011, 12:47 PM

Tags for this Thread

Posting Permissions