Hi,
I have the following grid:
@(Html.EJ().Grid<SlimHub.Models.QuoteSimulationPlantCost>("QuoteSimulationPlantCostsGrid")
.Datasource(ds => ds.Json((IEnumerable<QuoteSimulationPlantCost>)Model.QuoteSimulationPlantCosts.ToList()).UpdateURL("../PlantCostEqUpdate").InsertURL("../PlantCostEqInsert").RemoveURL("../PlantCostEqDelete").BatchURL("../PlantCostBatchUpdate").Adaptor(AdaptorType.RemoteSaveAdaptor))
.ShowSummary()
.SummaryRow(row =>
{
row.Title("Totale").SummaryColumns(col => { col.SummaryType(SummaryType.Sum).Format("{0:C}").DisplayColumn("TotalPrice").DataMember("TotalPrice").Add(); }).Add();
})
.EditSettings(edit =>
{
edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Batch);
})
.Locale("it-IT")
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Delete);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Cancel);
}).CustomToolbarItems(
new List<object>() {
//new Syncfusion.JavaScript.Models.CustomToolbarItem() {TemplateID = "#Details"},
new Syncfusion.JavaScript.Models.CustomToolbarItem() {TemplateID = "#Details"}});
})
.AllowResizing()
.AllowTextWrap(true)
.Columns(col =>
{
col.Field("PlantCostId").HeaderText("ID").HeaderTextAlign(TextAlign.Center).IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(40).Visible(true).AllowEditing(false).Add();
col.Field("QuoteSimId").HeaderText("ID Simulazione").HeaderTextAlign(TextAlign.Center).DefaultValue(Model.QuoteSimId).Width(100).Visible(true).AllowEditing(false).Add();
col.Field("EquipmentId").HeaderText("Attrezzatura").ForeignKeyField("EquipmentId").ForeignKeyValue("EquipmentDesc").DataSource((IEnumerable<object>)ViewBag.Equipments).HeaderTextAlign(TextAlign.Center).Width(80).Add();
col.Field("Quantity").HeaderText("Quantità").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Format("{0:n1}").EditType(EditingType.Numeric).NumericEditOptions(new Syncfusion.JavaScript.Models.EditorProperties() { DecimalPlaces = 2, MaxValue = 99999999.99, Locale = "it-IT", MinValue = 0 }).Width(30).Add();
col.Field("UnitPrice").HeaderText("Prezzo Unitario").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Format("{0:c2}").EditType(EditingType.Numeric).NumericEditOptions(new Syncfusion.JavaScript.Models.EditorProperties() { DecimalPlaces = 2, MaxValue = 99999999.99, Locale = "it-IT", MinValue = 0 }).Width(30).Add();
col.Field("TotalPrice").HeaderText("Prezzo Totale").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Format("{0:c2}").AllowEditing(true).Width(30).Add();
//col.Field("TotalPrice").HeaderText("Prezzo Totale").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Format("{0:c2}").AllowEditing(false).Width(80).Add();
col.Field("Annotations").HeaderText("Note").HeaderTextAlign(TextAlign.Center).Width(80).Add();
})
.ClientSideEvents(eve =>
{
eve.ActionComplete("PlantComplete");
eve.Create("PlantGridCreate");
eve.ToolbarClick("PlantToolBarClick");
eve.CellEdit("PlantCostsCellEdit");
eve.CellSave("PlantCostsCellSave");
eve.QueryCellInfo("CalculatePlantCostsTotalPrice");
eve.BeforeBatchSave("RefreshPlantCostsGrid");
})
)
***************************
Controller Batch Update Method
***************************
public ActionResult PlantCostBatchUpdate(string action, List<QuoteSimulationPlantCost> added,
List<QuoteSimulationPlantCost> changed, List<QuoteSimulationPlantCost> deleted, int? key)
{
if (added != null)
{
foreach (QuoteSimulationPlantCost qspc in added)
{
db.QuoteSimulationPlantCosts.Add(qspc);
}
}
else if (changed != null)
{
foreach (QuoteSimulationPlantCost qspc in changed)
{
qspc.TotalPrice = qspc.Quantity * qspc.UnitPrice;
db.Entry(qspc).State = EntityState.Modified;
}
}
else if (deleted != null)
{
foreach (QuoteSimulationPlantCost qspc in deleted)
{
QuoteSimulationPlantCost quotePlantCost = db.QuoteSimulationPlantCosts.Find(qspc.PlantCostId);
db.QuoteSimulationPlantCosts.Remove(quotePlantCost);
}
}
db.SaveChanges();
var data = db.QuoteSimulations.ToList();
return Json(data, JsonRequestBehavior.AllowGet);
}
---------------------------------------
When I add multiple rows (for example 4 rows) and click on the SAVE button, the 4 rows are added to the database but the last row has the same values of the first row added.
The attached file contains some screenshots that explains better the problem.
Some other details:
1) If I trigger the BeforeBatchSave event, the args parameter contains the added array with the correct 4 rows. When the added file is passed to the Controller method, it contains the two rows with the same values.
thanks.
Attachment:
issue_a7835aad.zip