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

[Solved] Grid Update button problem

1 Answer 136 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.
Milos
Top achievements
Rank 1
Milos asked on 20 Feb 2012, 08:09 PM
Hello guys, I've just got in touch with Telerik MVC extensions and I think that they are awesome!

But I've stumbled on small problem. It's probably me, but I just don't know what I am doing wrong.

My grid is inside bigger page, showing details for ViewModel of a page. Grid is using Ajax binding:

@(Html.Telerik().Grid<KontiranjeDokumentaVM>(Model.Kontiranja).Name("Kontiranja")
    .DataKeys(k => k.Add(m => m.IdKontiranjeDokumenta).RouteKey("IdKontiranjeDokumenta"))
    .ToolBar(t => t.Insert())
    .DataBinding(b => b.Ajax()
        .Select("Select", "Dokument")
        .Insert("Insert", "Dokument")
        .Update("Update", "Dokument")
        .Delete("Delete", "Dokument"))
    .Columns(c =>
    {
        c.Command(cmd => { cmd.Edit().ButtonType(GridButtonType.Text); cmd.Delete().ButtonType(GridButtonType.BareImage); });
        c.Bound(m => m.IdKontiranjeDokumenta).Hidden(true);
        c.Bound(m => m.Datum).Hidden(true);
        c.Bound(m => m.Key).Width("5%").
        c.Bound(m => m.Uslov).Title("Uslov za kreiranje stava").Width("10%").
        c.ForeignKey(m => m.StranaKnjizenja, new SelectList(ViewData["StraneKnjizenja"] as IEnumerable, "Key", "Text")).Width("5%");
        c.Bound(m => m.Iznos).Width("10%"));
        c.Bound(m => m.Partner).Width("10%"));
        c.Bound(m => m.OrgJed).Width("10%"));
        c.ForeignKey(m => m.Konto, new SelectList(ViewData["Konta"] as IEnumerable, "Key", "Text")).Width("15%"));
    })
    .Selectable().Filterable())


when i hover my mouse over edit button I get something like this:

http://localhost:9234/VrstaDokumenta/Edit/ZARADE?Kontiranja-mode=edit&IdKontiranjeDokumenta=2

and i successfully enter edit mode. But, when i want to update my changes (call my insert action of controller), NOTHING HAPPENS. Now when i hover over update button i get something like this:

http://localhost:9234/VrstaDokumenta/Edit/ZARADE#

I think that pound symbol is the problem, but i don't know what to do about it. I've tried adding some route values to my update ajax command but that didn't help:

.Update("Update", "Dokument", new { IdKontiranjeDokumenta = "<#= IdKontiranjeDokumenta #>" })

My Select, Insert and Delete Actions get called without any problems, it's just Update that wont get called.

I've been looking around forum but couldn't find any similar problem, which tells me that I am the problem, and I am probably missing someting presumed.

I would really appreciate any help to overcome this [small] obstacle because i cant wait to dig deeper.

Best regards,

1 Answer, 1 is accepted

Sort by
0
Ran
Top achievements
Rank 1
answered on 21 Feb 2012, 04:00 AM
在telerik grid控件中它默认的第一个字段是id,无论这个字段你是否绑定到grid中,所以你controller中的update方法的参数也只能名也只能是id(是必须用id这个参数名,其他都无效),这样才能把参数传到controller中,这样你在试下。。。
Tags
Grid
Asked by
Milos
Top achievements
Rank 1
Answers by
Ran
Top achievements
Rank 1
Share this question
or