This is a migrated thread and some comments may be shown as answers.

Form in detail template not serializing

0 Answers 71 Views
This is a migrated thread and some comments may be shown as answers.
Jark Monster
Top achievements
Rank 1
Jark Monster asked on 05 Sep 2012, 01:46 PM
I have a form within a detail template on each grid row.  I've got the field showing up in the detail template, and I can enter data.  However, when I submit my changes on the grid, the object that is serialized does not have the information that was entered into the detail template form.  Only the information entered into the 'proper' row is present.

Is there a way to easily serialize this detail template form data along with the rest of the row?

@model List<KendoUITestEnvironment.Models.ItemModel>
@using Kendo.Mvc.UI
<script id="ItemDetails" type="text/kendo-tmpl">
    <table id="hazmatDetailsTable">
            <td><label>Hazmat</label><input>#= HazmatClass #</input></td>
    .Columns(columns =>
        columns.Bound(i => i.FreightClass).Width(50);
        columns.Bound(i => i.Length).Width(50);
        columns.Bound(i => i.Width).Width(50);
        columns.Bound(i => i.Height).Width(50);
        columns.Bound(i => i.DimensionUnitOfMeasure).Width(50);
        columns.Bound(i => i.QuantityValue).Width(50);
        columns.Bound(i => i.QuantityUnitOfMeasure).Width(50);
        columns.Bound(i => i.Weight).Width(50);
        columns.Bound(i => i.WeightUnitOfMeasure).Width(50);
        columns.Bound(i => i.NmfcCode).Width(50);
        columns.Bound(i => i.ItemDescription).Width(50);
        columns.Command(command => command.Destroy()).Width(110);
    .ToolBar(toolbar =>
    .Editable(editable => editable.Mode(GridEditMode.InCell))
    .DataSource(dataSource => dataSource
        .Events(events => events.Error("QuoteItemGrid_ErrorHandler"))
        .Model(model =>
            model.Id(i => i.ItemID);
            model.Field(i => i.FreightClass);
        .Create(create => create.Action("CreateProducts", "Home"))
        .Read(read => read.Action("GetProducts", "Home"))
        .Update(update => update.Action("UpdateProducts", "Home"))
        .Destroy(destroy => destroy.Action("DeleteProducts", "Home"))

public ActionResult CreateProducts([DataSourceRequest]DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<Models.ItemModel> itemsToAdd)
    Models.ShipmentModel shipmentModel = SessionModel;
    var results = new List<Models.ItemModel>();
    foreach (Models.ItemModel newItem in itemsToAdd)
        if (shipmentModel.ItemModelList.Count > 0)
            var nextID = (from i in shipmentModel.ItemModelList
                          select i.ItemID).Max() + 1;
            newItem.ItemID = nextID;
    return Json(results.ToDataSourceResult(request, ModelState));

No answers yet. Maybe you can help?

Asked by
Jark Monster
Top achievements
Rank 1
Share this question