I use a gridview with inline editing, when i Update a double value with
This is the grid :
@(Html.Kendo().Grid<
Ubaldi.BoB2B.Web.Models.FraisDePort.FraisDePortViewModel
>()
.Name("FraisGrid")
.Columns(columns =>
{
columns.Bound(e => e.Id).Hidden(true);
columns.Bound(e => e.Article);
columns.Bound(e => e.PoidsMin).ClientTemplate("#= PoidsMin # kg");
columns.Bound(e => e.PoidsMax).ClientTemplate("#= PoidsMax # kg");
columns.Bound(e => e.MontantHT).ClientTemplate("#= MontantHT # €");
columns.Command(command => { command.Edit().UpdateText("Enregistrer").CancelText("Annuler").Text(" ");}).Width(100);
columns.Command(command =>
{
command.Custom("Logs").Click("FraisLogs")
.Text("<
span
class
=
'fa fa-list-alt'
></
span
>")
.HtmlAttributes(new { @class = "btn btn-info", title = "Voir les modifications effectuées sur l'Article de Transport" });
}).Width(50);
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error_handler"))
.Read(read => read.Action("GetAll", "FraisDePort"))
.Update(update => update.Action("Update", "FraisDePort").Data("addUser"))
.Model(model =>
{
model.Id(p => p.Id);
})
.PageSize(20)
)
.Pageable(pageable => pageable.ButtonCount(5)))
This is my View Model:
public
class
FraisDePortViewModel : IValidatableObject
{
public
int
Id {
get
;
set
; }
[Required, StringLength(100, MinimumLength = 3, ErrorMessage =
"Le Nom de l'Article de Transport doit faire entre 3 et 100 charactères"
)]
[DisplayName(
"Article de Transport"
)]
public
string
Article {
get
;
set
; }
[Required]
[UIHint(
"Poids"
)]
public
double
? PoidsMin {
get
;
set
; }
[Required]
[UIHint(
"Poids"
)]
public
double
? PoidsMax {
get
;
set
; }
[UIHint(
"Currency"
)]
[Required, Range(1, 9999, ErrorMessage =
"Le Montant HT doit être supérieur à 0 €"
)]
public
decimal
? MontantHT {
get
;
set
; }
[DisplayFormat(DataFormatString =
"{0:dd/MM/yyyy HH:mm}"
, ApplyFormatInEditMode =
true
)]
[DisplayName(
"Créé le"
)]
public
DateTime? DateCreation {
get
;
set
; }
[DisplayName(
"Créé par"
)]
public
string
UserCreation {
get
;
set
; }
[DisplayFormat(DataFormatString =
"{0:dd/MM/yyyy HH:mm}"
, ApplyFormatInEditMode =
true
)]
[DisplayName(
"Modifié le"
)]
public
DateTime? DateModification {
get
;
set
; }
[DisplayName(
"Modifié par"
)]
public
string
UserModification {
get
;
set
; }
public
List<FraisDePortLog> Modifications {
get
;
set
; }
public
IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if
(PoidsMin > PoidsMax)
{
yield
return
new
ValidationResult(
"Le Poids Minimum doit être supérieur au Poids Maximum "
,
new
List<
string
> {
"Poids"
});
}
}
}
This is my EditorTemplate "Poids"
@model double?
@(Html.Kendo().NumericTextBoxFor(m => m)
.Culture("fr-FR")
.Min(0)
.Max(15)
.Step(0.50))
This is what i receive when I post modification with decimals (see Attachement).
Additionnals info :
- Kendo 2018.3.911.545
- Culture is set to fr-FR in web.config solution
Do you have an idea to fix this issue of null value ?
Thank you,
Julien