This question is locked. New answers and comments are not allowed.
I am using the Grid in the batch update/edit mode. I have a div/td outside of the grid to which I have to display sum of one of the grid columns. I tried using the viewbag approach, but though the value in view bag is updated everytime the sum changes, the value in the div/td does not change. The value that is computed when the page first time loads is the one that is always displayed.
Here is my code:
here is my controller :
And in the view page I am trying to display the value as :
<td>
@ViewBag.SumOfQuotaValues.SumValue
</td>
Why is display on the UI not changing when there is change in the controller values and the viewbag value is updated??
Can I access the aggregate value and use it to display in the div/td??
Pls help, I am new to both telerik and mvc
Here is my code:
@(Html.Telerik().Grid<SampleMyComp.Models.Quota>("quota") .Name("Grid") .Editable(editing => editing.Mode(GridEditMode.InCell)) .DataKeys(keys => { keys.Add(k => k.QuotaId); }) .Columns(columns => { columns.Bound(e => e.TerritoryName).Width(100); columns.Bound(e => e.ISSValue).Width(100) .Aggregate(aggreages => aggreages.Sum()) .FooterTemplate(result => result.Sum) .ClientFooterTemplate("Total Sum: <#= Sum #>"); //more columns here columns.Bound(e => e.HPSDValue).Width(120) .Aggregate(aggreages => aggreages.Sum()) .FooterTemplate(result => result.Sum) .ClientFooterTemplate("Total Sum: <#= Sum #>"); }) .DataBinding(dataBinding => dataBinding.Ajax() .Select("AjaxBinding", "Home") .Update("AjaxUpdate", "Home") ) .ToolBar(tools => { tools.Insert(); tools.SubmitChanges(); }) .ClientEvents(events => events .OnEdit("onEdit") .OnSubmitChanges("onSubmitChanges") .OnComplete("onComplete") .OnDataBound("onDataBound")) .Sortable() .Pageable() )public ActionResult Index() { QuotaData quotadata = new QuotaData(); ViewBag.quota = quotadata.GetQuota(); CategoryData prod = new CategoryData(); ViewData.Model = prod.GetCategory(); SetTotalValues(); return View(); }[GridAction] public ActionResult AjaxBinding() { SetTotalValues(); return View(new GridModel(QuotaRepository.All())); } [AcceptVerbs(HttpVerbs.Post)] [GridAction] public ActionResult AjaxUpdate( [Bind(Prefix = "inserted")]IEnumerable<Quota> insertedQuota, [Bind(Prefix = "updated")]IEnumerable<Quota> updatedQuota, [Bind(Prefix = "deleted")]IEnumerable<Quota> deletedQuota){//updates to data done here SetTotalValues(); //calculate new sum values return View(new GridModel(QuotaRepository.All()));} private void SetTotalValues() { //Do sum calulation here and add value to viewbag. ViewBag.SumOfQuotaValues = sumDetails; }<td>
@ViewBag.SumOfQuotaValues.SumValue
</td>
Why is display on the UI not changing when there is change in the controller values and the viewbag value is updated??
Can I access the aggregate value and use it to display in the div/td??
Pls help, I am new to both telerik and mvc