NumberFieldControls how to be able to save and display 0's?

  1. #1

    NumberFieldControls how to be able to save and display 0's?

    Hi,
    I have 5 dimension fields length, width, height, diamteter, net weight, and gross weight using the NumberField control and I can't seem be able to save 0's to the database or display them on the application. Is there anyway around this?


    This might be such a broad question without looking into the exact code, but another example would be trying to save 00123 without taking the 0's away.
  2. #2
    Hello @juan!

    You should set up number formatting. This might require using a renderer if you want to display the leading zeros in the grid. If you just need to pad the zeroes when saving the data to the server, you should use C# number formatting to convert from integer to the formatted string specification you need.

    You can also just send the number from server-side already padded with zeroes, and treat it as string in the display grid. But you can keep its numeric representativity (pass as a non-padded integer) and just format the display at client side, using the renderer, with the Ext.String.leftPad() client-side method.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3

    more questions

    Hi fabricio.murta,

    than k you for your reply, how exactly would I usenumber formatting with a renderer..? (I am fairly new to ext.js)
  4. #4
    Hello again, @juan!

    I didn't notice first you specified using the Ext.Net.NumberField, sorry. In fact, the component does not have an obvious means to format its display value. The only way that could be possible would be by extending the component, which is maybe not a good idea for who's still learning it.

    I suggest you use a TextField, with an input mask to keep it formatted the way you need it. Take a look in these examples:
    - Form > TextField > InputMask (Ext.NET-specific)
    - Form > TextField > InputMask Native (introduced by Ext JS recently)

    You may miss the spinner, but you can with more ease implement buttons to increment/decrement the read amount with RightButtons: Form > TextField > Buttons; so you can just interpret current value in the field, increment/decrementing (depending on the clicked button), then let the input mask do the fancy formatting of the value.

    Hope this (now) helps!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. CalendarPanel Save in any changes
    By rammus in forum 2.x Help
    Replies: 0
    Last Post: Mar 08, 2013, 12:33 PM
  2. Replies: 1
    Last Post: Jul 27, 2011, 10:19 AM
  3. Replies: 0
    Last Post: Aug 26, 2010, 2:58 PM
  4. Replies: 3
    Last Post: Jul 14, 2009, 9:47 PM
  5. How to save the many data
    By wkcode in forum 1.x Help
    Replies: 1
    Last Post: Feb 28, 2009, 3:39 AM

Posting Permissions