ThemedDataGridFor with Ajax edit dialog

May 13, 2011 at 2:57 PM


I'm trying use the ThemedDataGridFor with the Ajax dialog to edit an item from the grid. The first time that the dialog is opened it load the data from the item, but if I change an field and click in the save button and close the dialog, if I open again it don't load the updated data, but keep the old field data (without changes).

If I stop the application and start again, my change in the field is refreshed.

I did the debug the Action from the controller is called only in the first time that the dialog is opened.

This is the code in the grid:(...)
.Add(m => m.proj_codigo, FieldFeatures.Hidden,
                displayTemplate: _S.H<ProjetoView>(
                        @item.DetailLink(Ajax, "Edit Details", DetailType.Edit, "Edit", "Projeto",
                                     new { id = item.ViewData.Model.proj_codigo}, null)
And this is the dialog in the end of the page:

@{ Html.DetailFormFor(Ajax, m => m.ModelList, ExternalContainerType.span,
           "Edit", "Projeto", null, "isChangedToDo", "isDeletedToDo", detailDialog:
           new MVCControlsToolkit.Controls.DataGrid.Dialog
               Title = "Editar",
               Show = "slide",
               Hide = "slide",

Can you help me? Thanks!

May 13, 2011 at 8:47 PM

99% the result of the action method called via Ajax by the detail form is cached, so you get always the same result, and the action method is just called the first time.

All children actions are cached by default in Asp.Net MVC. To avoid caching add a cache attribute to the action method:

[System.Web.Mvc.OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")] 

May 16, 2011 at 1:08 PM

It worked, thank you!