Update Method not receiving IEnumerable Object

2 posts, 0 answers
  1. Christopher
    Christopher avatar
    2 posts
    Member since:
    Apr 2019

    Posted 07 Jun 2019 Link to this post

    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"))
            )
    )

  2. Christopher
    Christopher avatar
    2 posts
    Member since:
    Apr 2019

    Posted 07 Jun 2019 in reply to Christopher Link to this post

    Please ignore this thread, I will log a support ticket on this.
Back to Top