Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Number formats in form edit, decimal point or comma
14/06/2010
22:00
Avatar
caroig
Spain
New Member
Members
Forum Posts: 1
Member Since:
14/06/2010
sp_UserOfflineSmall Offline

Hi,

I'm using v3.6.5 and it works great.  But I have a problem with my number formats.  My system is in spanish and I'm loading the spanish localization and using formatter to get the grid data displaying correctly - so far so good.  

I'm using formatter in my colModel and all my floats display fine with a comma decimal separator (e.g. 12,53).  When I come to edit or add new rows, the data displayed in the popup form shows floats with a dot seperator (e.g. 12.53).

If I enter numbers in the edit form with the dot decimal separator e.g. 12.53 - they are displayed correctly in the grid e.g. 12,53.  

If I enter data in the form with the comma separator, I get a validation error (from formatter I guess) that the field is not numeric.

What do I need to do to ensure that my form displays and validates numbers with a comma decimal seperator.

P.S. My data is not bound I use a dummy fille for the editurl and set reloadAfterSubmit:false on edit

20/06/2010
11:15
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

You can avoid this, suppessing the checking und use your own formatter and unformatter to return the original value.

The reason that you have a error when you enter a number with decimal separator "," is that the javascript isNaN function work only with numbers that have decimal separator ".".

Also you can define your own validator for your number.

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

24/07/2012
20:58
Avatar
wizrd66
Member
Members
Forum Posts: 4
Member Since:
28/01/2012
sp_UserOfflineSmall Offline

I am having the exact same issue.

I am doing an inline edit and the language settings are set to spanish. So the number formatting is a comma for decimalseparator and period for thousands separator.  We have written unformat and format functions all is good there.
When a user edits a row, and they lets put in 26000,50 and they hit enter. The Grid throws an error. where 26000.50 is ok. Our users want to be able to put in a comma. I have seen posting on this and no real suitable fix ..  It seems to me that this would be a common request and that being able to enter a number in the lanquage type you have selected would be expected.
 
I tracked the issue down to this section of code, in the jqgrid code in the checkvalues function.
 
 
if(edtrul.number === true) {
if( !(rqfield === false && this.isEmpty(val)) ) {
if(isNaN(val)) { return [false,nm+": "+$.jgrid.edit.msg.number,""]; }
}
the isNaN(val) check of course fails..  
I was wondering wouldn't 
if(isNaN(val.replace(opts.decimalSeparator,".")))
Be a better check? or is there someway to run unformat on this before is runs the saverow function?
I would think you would re-run unformat after the user edits the data for a row. 
 
if(edtrul) {
			if(!nm) { nm = g.p.colNames[valref]; }
			if(edtrul.required === true) {
				if( this.isEmpty(val) )  { return [false,nm+": "+$.jgrid.edit.msg.required,""]; }
			}
			// force required
			var rqfield = edtrul.required === false ? false : true;
			if(edtrul.number === true) {
				if( !(rqfield === false && this.isEmpty(val)) ) {
					if(isNaN(val)) { return [false,nm+": "+$.jgrid.edit.msg.number,""]; }
				}
25/07/2012
17:12
Avatar
wizrd66
Member
Members
Forum Posts: 4
Member Since:
28/01/2012
sp_UserOfflineSmall Offline

 To fix this issue, I changed from using the built in edtrul.number to use edtrul.custom

sim to this

col.editrules.custom = true;
 col.editrules.custom_func = (function (val, nm) { if (isNaN(val.replace(decimalsep, '.'))) { return [false, nm + ": " + $.jgrid.edit.msg.number] } return [true, ""] });
Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
25 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information