I have been trying out the Kendo UI MVC Grid and have now faced a problem I could use some help with while trying to implement the batch editing functionality:
1. Data that is displayed in the grid has dots as decimal separators while the culture setting would use commas. Regardless of the culture setting, any model data that the grid passes to the update method is invalid because the decimal values are validated incorrectly.
2. For some reason, the grid doesn't allow me to edit numeric fields (nullable double) at all. Clicking the cell clears the field but doesn't show me a real editor or allow me to change the value.
Thank you.
View:
@(Html.Kendo().Grid<ExpakV2.Models.GridViewResult>()
.Name(
"Grid"
)
.Columns(columns =>
{
columns.Bound(p => p.ItemID).Width(
"10%"
).Title(i18n.s(
"itemCode"
));
columns.Bound(p => p.Code).Width(
"10%"
).Title(i18n.s(
"itemCode"
));
columns.Bound(p => p.Name).Width(
"25%"
).Title(i18n.s(
"itemName"
));;
columns.Bound(p => p.ItemGroup1).Width(
"10%"
).Title(i18n.s(
"itemGroup1"
));
columns.Bound(p => p.ItemGroup2).Width(
"10%"
).Title(i18n.s(
"itemGroup2"
));
columns.Bound(p => p.ItemGroup3).Width(
"15%"
).Title(i18n.s(
"itemGroup3"
));
columns.Bound(p => p.AbcClass).Width(
"5%"
).Title(i18n.s(
"abcClass"
));
columns.Bound(p => p.MinBalance).Width(
"5%"
).Title(i18n.s(
"minBalance"
)).Format(
"{0:0.####}"
);
columns.Bound(p => p.MaxBalance).Width(
"5%"
).Title(i18n.s(
"maxBalance"
)).Format(
"{0:0.####}"
);
columns.Bound(p => p.MinBalanceRate).Width(
"5%"
).Title(i18n.s(
"minBalanceRate"
)).Format(
"{0:0.####}"
);
columns.Bound(p => p.MaxBalanceRate).Width(
"5%"
).Title(i18n.s(
"maxBalanceRate"
)).Format(
"{0:0.####}"
);
columns.Bound(p => p.sum_of_quantities).Width(
"5%"
).Title(i18n.s(
"sum_of_quantities"
)).Format(
"{0:0.####}"
);
columns.Bound(p => p.avg_of_quantities).Width(
"5%"
).Title(i18n.s(
"avg_of_quantities"
)).Format(
"{0:0.####}"
);
columns.Bound(p => p.sum_of_value).Width(
"5%"
).Title(i18n.s(
"sum_of_value"
)).Format(
"{0:0.####}"
);
columns.Bound(p => p.avg_of_value).Width(
"5%"
).Title(i18n.s(
"avg_of_value"
)).Format(
"{0:0.####}"
);
columns.Bound(p => p.Unit).Width(
"5%"
).Title(i18n.s(
"itemUnit"
));
columns.Bound(p => p.AvgPrice).Width(
"5%"
).Title(i18n.s(
"avgPrice"
)).Format(
"{0:0.####}"
);
columns.Bound(p => p.Location).Width(
"5%"
).Title(i18n.s(
"location"
));
})
.Pageable()
.Reorderable(conf => conf.Columns(
true
))
.Scrollable()
.Filterable()
.Sortable()
.Resizable(resize => resize.Columns(
true
))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action(
"GetDataForKendoGrid"
,
"Sale"
))
.Model(model => { model.Id(p => p.ID); })
.Update(
"EditItemInKendoGrid"
,
"Sale"
)
.PageSize(100)
)
.ToolBar(toolbar => { toolbar.Save(); })
.Editable(editable => editable.Mode(GridEditMode.InCell))
)
Controller actions:
Model:
public
class
GridViewResult
{
public
int
ID {
get
;
set
; }
public
string
ItemID {
get
;
set
; }
public
string
Code {
get
;
set
; }
public
string
Name {
get
;
set
; }
public
string
Supplier {
get
;
set
; }
public
string
AbcClass {
get
;
set
; }
public
double
? MinBalance {
get
;
set
; }
public
double
? MaxBalance {
get
;
set
; }
public
double
? MinBalanceRate {
get
;
set
; }
public
double
? MaxBalanceRate {
get
;
set
; }
public
string
Unit {
get
;
set
; }
public
double
? AvgPrice {
get
;
set
; }
public
int
? Location {
get
;
set
; }
public
string
ItemGroup1 {
get
;
set
; }
public
string
ItemGroup2 {
get
;
set
; }
public
string
ItemGroup3 {
get
;
set
; }
public
double
? sum_of_quantities {
get
;
set
; }
public
double
? avg_of_quantities {
get
;
set
; }
public
double
? sum_of_value {
get
;
set
; }
public
double
? avg_of_value {
get
;
set
; }
}