I have a model with the following definition:
[Display(Name = "Quantidade / Volume:")]
public Int32 RoQuantidade { set; get; }
In my View to fill in the data when empty, that is, that have not yet been written, using maskMoney
works without problems. I use the following form:
$('#RoQuantidade').maskMoney({
showSymbol: false,
symbol: "R$",
decimal: ",",
thousands: ".",
allowZero: true,
allowNegative: false,
precision: 0
});
Please note that the accuracy is zero because I do not need decimal places in this case.
The problem starts when I retrieve the information from the data source. In my controller
I retrieve the information like this:
model.RoQuantidade = Convert.ToInt32(_sheet.Cells[lin, 3].value2);
I'm getting information from an Excel spreadsheet, but that's not the problem. It turns out that the return to the view same as removing the mask or trying to convert, always return as follows:
- Original value: 30000
- Value returned to view : 30000,00
If I use maskMoney
the way I put it up with an extra parameter that is
$('#Disponivel').maskMoney({
showSymbol: false,
symbol: "R$",
decimal: ",",
thousands: ".",
allowZero: true,
allowNegative: true
}).maskMoney('mask', $('#Disponivel').val());
To format the returned value it displays the value: 3,000,000, because the field being decimal added the two zeroes transforming from 30 thousand to 3 million
I tried to change the definition of the field to int32
, however the formatting is in trouble and at the time of recording it informs that there is an error because it can not write 30,000 (notice that it changed even with the correct definition of the point by the comma) .
I have tried to use other jquery plugins like maskedit, but I was not able to do it, especially when the information is returned.
If you have any idea how I can do to fill the formatted value, save the information without formatting, recover the information without formatting and present in a formatted form, there is no problem changing from decimal
to another type, only I need to make him respect the situation I described above.
I'll leave some images below that illustrate what I'm saying: