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

Update Method not receiving IEnumerable Object

1 Answer 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christopher
Top achievements
Rank 1
Christopher asked on 07 Jun 2019, 03:45 PM

Hello,

I am using a Grid Custom Editor for ASP.NET MVC.  When updating, the CohortAttributes_Update method is called (verified by breakpoint in Visual Studio), however IEnumerable<ContractMultiselectXrefModel>  contractMultiSelectXrefs is set to a null value.  I have followed this guide for implementation: https://demos.telerik.com/aspnet-mvc/grid/editing-custom

ContractMultiselectXrefsController
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult CohortAttributes_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<ContractMultiselectXrefModel> contractMultiSelectXrefs)
        {
            db.Configuration.ProxyCreationEnabled = false;
            if (contractMultiSelectXrefs != null && ModelState.IsValid)
            {
                foreach (var contractMultiSelectXref in contractMultiSelectXrefs)
                {
                    contractMultiselectService.Update(contractMultiSelectXref);
                }
            }
            return Json(contractMultiSelectXrefs.ToDataSourceResult(request, ModelState));
        }

Index.cshtml
    @(Html.Kendo().Grid<HI_ACO_Tool.Models.RAD.ContractFeeXrefModel>
        ()
        .Name("CohortFees")
        .Columns(columns =>
        {
            columns.Bound(contract => contract.ContractFeeModel).ClientTemplate("#=ContractFeeModel.FeeNM#").Title("Fee");
            columns.Bound(contract => contract.Amount);
            columns.Bound(contract => contract.BeginDT).Title("Attribute start date").Format("{0: MM/dd/yyyy}");
            columns.Bound(contract => contract.EndDT).Title("Attribute end date").Format("{0: MM/dd/yyyy}");
            columns.Command(command => { command.Destroy(); }).Width(100);
        })
        .ToolBar(toolBar =>
        {
            toolBar.Create().Text("Add Fee");
            toolBar.Save();
        })
        .Editable(editable => editable.Mode(GridEditMode.InCell))
        .DataSource(dataSource => dataSource // Configure the grid data source
        .Ajax()
        .ServerOperation(false)
        .Model(model =>
        {
            model.Id(p => p.FeeXrefKey);
            model.Field(p => p.ContractCohortKey);
            model.Field(p => p.FeeKey);
            model.Field(p => p.ContractFee);
            model.Field(p => p.Amount);
            model.Field(p => p.BeginDT);
            model.Field(p => p.EndDT);
        })
        .Read(read => read.Action("ContractFeeGrid_Read", "ContractFee").Data("cohortInfo()"))
        .Update(update => update.Action("ContractFeeGrid_Update", "ContractFee"))
        )
)

1 Answer, 1 is accepted

Sort by
0
Christopher
Top achievements
Rank 1
answered on 07 Jun 2019, 03:49 PM
Please ignore this thread, I will log a support ticket on this.
Tags
Grid
Asked by
Christopher
Top achievements
Rank 1
Answers by
Christopher
Top achievements
Rank 1
Share this question
or