This question is locked. New answers and comments are not allowed.
Hi All,
Here's an update on my original problem.
My partial view starts:
My Risk view model That populates the grid come from a complex type on the ViewModel:
Now when I receive the popup on screen when I get into the controller declared as :
cover now passes the values from the popup. I have a couple of problems. At this point I do not want to save the data against the context thus updating the database, I only want to update the main view. If I attempt to pass the complete model everything is null and I suspect this is because I have not passed the whole view on the Grid i.e.
update.........
changing my databinding (using the Q2 release)....
then in my controller
my cover hold details from the popup as I want, but the viewmodel is empty this is my problem. If I can get the base viewmodel passing in as well, I would be able to do what I want. to help visualise my problem I have attached a screenshot. the grid has been populated with default values, at this point when the user presses an edit button the popup appears, when I press the update button on the popup I only want to update the dingle line on the grid without doing a full postback to the DB. THe postback to the DB happens on the Save Button.
Here's an update on my original problem.
My partial view starts:
@model GRID.ViewModels.ComputerBreakdownRiskViewModel@{ ViewBag.Title = "Index";}@Html.Hidden("policyZoneID", ViewData["policyZoneID"])@Html.Hidden("sectionID", ViewData["sectionID"])@(Html.Telerik().Grid(Model.Covers) .Name("risksGrid") .Sortable() .DataKeys(keys => keys.Add(r => r.Id)) .DataBinding(dataBinding => { dataBinding.Ajax() .Update("_SaveAjaxEditing", "ComputerBreakdownRisk", Model.Covers); })My Risk view model That populates the grid come from a complex type on the ViewModel:
public IEnumerable<CoverType> Covers { get; set; } #region Complex Types public class CoverType { [ScaffoldColumn(false)] public int Id { get; set; } public string Name { get; set; } public int SumInsured { get; set; } public decimal Rate { get; set; } public int Excess { get; set; } public decimal IncreasedXSDiscount { get; set; } public bool UseDiscount { get; set; } [ScaffoldColumn(true)] [UIHint("NotEnabledForMoney")] public decimal TechnicalPrice { get; set; } } #endregion #region LookUp Type Properties public IEnumerable<SelectListItem> CoverTypes { get; set; } #endregionNow when I receive the popup on screen when I get into the controller declared as :
[AcceptVerbs(HttpVerbs.Post)] [GridAction] public ActionResult _SaveAjaxEditing(int Id, ComputerBreakdownCover cover) { cover.CBCoverTypeID = Id; cover.CreatedBy = "Test"; cover.CreatedOn = DateTime.Today; cover.ModifiedOn = DateTime.Today; return View(new GridModel(cover)); }@(Html.Telerik().Grid<GRID.ViewModels.ComputerBreakdownRiskViewModel>()If I attempt to return as above, I receive an error that states that it's not IEnumerable. All I want to do is pass the original view along with the cover. Take the cover values in the controller update the viewmodel and return. Further in my page I have a main save button, which is where I want to post everything back to the database.
update.........
changing my databinding (using the Q2 release)....
dataBinding.Ajax() .OperationMode(GridOperationMode.Client) .Update("_SaveAjaxEditing", "ComputerBreakdownRisk", new { this.Model, Model.Covers });[AcceptVerbs(HttpVerbs.Post)] [GridAction] public ActionResult _SaveAjaxEditing(int Id, ComputerBreakdownRiskViewModel viewModel, ComputerBreakdownCover cover) { cover.CBCoverTypeID = Id; cover.CreatedBy = "Test"; cover.CreatedOn = DateTime.Today; cover.ModifiedOn = DateTime.Today; IEnumerable<ComputerBreakdownRiskViewModel.CoverType> coverFlatData = _gridService.PopGrid(cover); // viewModel.Covers = coverFlatData; return View(new GridModel(coverFlatData)); }