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

Insert action in ajax binding is not called

2 Answers 50 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.
Arjun Paudel
Top achievements
Rank 1
Arjun Paudel asked on 28 Jul 2011, 06:21 AM
Hi,
I have following in view.
@( Html.Telerik().Grid<SMS.Models.Student.StudenRelativeGridItemViewModel>()
        .Name("GridRelations")
                .ToolBar(commands => { commands.Insert().ButtonType(GridButtonType.Image);
                                         commands.SubmitChanges().ButtonType(GridButtonType.Image);
                                     })
         .DataKeys(keys =>
                       {
                           keys.Add(p => p.RelativeID).RouteKey("id");
                           keys.Add(p => p.StudentID).RouteKey("studentid");
                       })
       .Columns(columns =>
        {
            columns.Bound(o => o.FirstName).Width(120).ReadOnly();
            columns.Bound(o => o.LastName).Width(120);
            columns.Bound(o => o.Relation).Width(80);
            columns.Bound(o => o.EmailAddress).Width(100).Title("Email");
            columns.Bound(o => o.HomeNumber).Width(100);
 
            columns.Command(commands =>
            {
                commands.Edit().ButtonType(GridButtonType.ImageAndText);
                commands.Delete().ButtonType(GridButtonType.ImageAndText);
            }).Width(180).Title("Commands");
 
 
 
        })
                .DataBinding(dataBinding => dataBinding.Ajax().Select("_GetStudentRelatives", "Students", new
                                                                                               {
                                                                                                                      })
                                                                                               .Update("SaveStudentRelations", "Students")
                                                                                               .Delete("DeleteParentGuardian", "Students")
                                                                                                       .Insert("InsertStudentRelations", "Students")
          )
 
 
        .Scrollable(scrolling => scrolling.Enabled(true))
        .Sortable(sorting => sorting.Enabled(true))
        .Pageable(paging => paging.Enabled(true))
        .Filterable(filtering => filtering.Enabled(true))
        .Groupable(grouping => grouping.Enabled(true))
        .Editable(editable=> editable.Mode(GridEditMode.InCell))
       .Footer(true)
 
)
And controller

private GridModel gridStudentRelatives(int studentid)
{
var query = _gridstudenRelationViewModelBuilder.Build(studentid);
return new GridModel(query);
}
[GridAction]
public ActionResult DeleteParentGuardian(int studentid, int id)
{
_studentRelativeService.DeleteRelative(id);
return View(gridStudentRelatives(studentid));
}
[GridAction]
public ActionResult SaveStudentRelations(int studentid, int id)
{
_studentRelativeService.SaveRelative(id);
return View(gridStudentRelatives(studentid));
}
 
[GridAction]
public ActionResult InsertParentGuardian(int studentid, int id)
{
_studentRelativeService.InsertRelative(id);
return View(gridStudentRelatives(studentid));
}

with add new records,InsertParentGuardian is never called. If I type it in address bar it looks fine. But clicking Add new records add an inline row in the grid without calling Action method(I used breakpoint to verify). All other GridActions are called without problem(i.e. save, delete) Would be very grateful if anyone could help me. Thanks

2 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 28 Jul 2011, 07:51 AM
Hi Arjun Paudel,

The described behavior is caused by the fact that InCell editing mode is used. When in this mode only the update action will be used as shown in this online demo example.

All the best,
Rosen
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

0
Arjun Paudel
Top achievements
Rank 1
answered on 28 Jul 2011, 01:13 PM
Thanks Rosen for your prompt reply, actually I tried all possibilities but no luck, even without batch update
http://demos.telerik.com/aspnet-mvc/grid/editingajax
I even looked at F12 tools and all jquery looked strange to me, I hope its not cached value of another grid. Anyway I am happy with actionlink and works seemlessly. I will give it a look again when I have some spare time and let you know the result.
Thanks

Tags
Grid
Asked by
Arjun Paudel
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Arjun Paudel
Top achievements
Rank 1
Share this question
or