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

[Solved] Ajax editing on a two level grid hierarchy

1 Answer 32 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Fabiano
Top achievements
Rank 1
Fabiano asked on 24 May 2011, 03:10 AM
Hi, I have a two level hierarchy grid using ajax binding.
On the second level, the record can be editted in a popup dialog. 
Everything is working fine, the method on the controller is being called when the user clicks on the "ok" button in the popUp edit dialog, the record is updated to the database and the GridModel is returned, but the popup remains opened and the underlying grid does not gets updated. Am I missing something?

My detail view code...

.DetailView(details => details.ClientTemplate(
            Html.Telerik().Grid<Gefico.Domain.Financeiro.AgenciaBancaria>()
            .Name("grid-agencias-<#= ID #>")
            .Localizable("pt-BR")
            .DataKeys(keys => keys.Add(a => a.ID))
            .Columns(columns =>
                {
                    columns.Bound(ag => ag.Banco.ID);
                    columns.Bound(ag => ag.Codigo);
                    columns.Bound(ag => ag.Telefone);                    
                    columns.Command(cmd =>
                        {
                            cmd.Edit().ButtonType(GridButtonType.BareImage);
                            cmd.Delete().ButtonType(GridButtonType.BareImage);
                        });
                })
                .Editable(editing =>
            editing.Mode(GridEditMode.PopUp).DisplayDeleteConfirmation(true))
            .DataBinding(dataBinding => dataBinding.Ajax()
                .Select("AjaxSelect", "AgenciaBancaria", new { idBanco = "<#= ID #>" })
                .Delete("AjaxDelete", "AgenciaBancaria")
                .Update("AjaxSave", "AgenciaBancaria", new { idBanco = "<#= ID #>" })
            )              
            .Pageable()
            .Sortable()
            .ToHtmlString()
        )
    )

 ... and my update controller method:
[GridAction]
[HttpPost]
public ActionResult AjaxSave(AgenciaBancaria model, long idBanco)
{
    model.Banco.ID = idBanco;
    Mapper.Save(model);
    List<AgenciaBancaria> result = Mapper.LoadAll().Where(ag => ag.Banco.ID == idBanco).ToList();
    return View(new GridModel(result));            
}


Thanks!

 

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 24 May 2011, 06:57 AM
Hello Fabiano,

 The popup form will remain visible if there are any ModelState errors. You can check with the debugger if this is the case and address those errors.

Greetings,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Fabiano
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or