1
I have a model with the following definition:
[Display(Name = "Quantidade / Volume:")]
public Int32 RoQuantidade { set; get; }
In my View to fill the data when empty, that is, that have not yet been written, using the maskMoney
works smoothly. I use it as follows:
$('#RoQuantidade').maskMoney({
showSymbol: false,
symbol: "R$",
decimal: ",",
thousands: ".",
allowZero: true,
allowNegative: false,
precision: 0
});
Note that I inform you that the accuracy is zero, as I do not need decimal places in this case.
The problem begins when I will 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 picking up the information from an Excel spreadsheet, but that’s not the problem. It turns out that the return to the view even if I remove the mask or try to convert, always return in the following way:
- original value: 30000
- Value returned to the view: 30000.00
If I use the maskMoney
the way I put it above 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 presents the value: 3.000.000, because the field to be decimal added the two zeroes transforming from 30 thousand to 3 million
I’ve tried changing the field setting to int32
, however the formatting gets in trouble and at the time of recording informs that there is error as it cannot record 30,000 (note that it changed even with the correct definition the point by the comma).
I tried to use other jquery plugins like maskedit, but I could not, especially when returning the information.
If you have any idea how I can do to fill in the formatted value, record the information without formatting, retrieve the information without formatting and present it in formatted form, it is no problem to change it decimal
for another guy, I just need to make sure he respects the situation I described above.
I will leave some images below that illustrate what I am saying: