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

Custom Command and Ajax Binding

1 Answer 478 Views
Grid
This is a migrated thread and some comments may be shown as answers.
App Dev Tools
Top achievements
Rank 1
App Dev Tools asked on 02 Aug 2013, 04:04 PM
@(Html.Kendo().Grid<TrainingVideo>()
.Name("grid")
.Columns(columns =>
    {
        columns.Bound(x => x.Name);
        columns.Bound(x => x.Description);
        columns.Bound(x => x.LastUpdateDate);
        columns.Command(commands => commands.Custom("EditVideoCommand")
                                            .Text("Edit")
                                            .DataRouteValues(route => route.Add(o => o.VideoUID).RouteKey("videoId"))
                                            .Action("EditSelectedVideo", "Home"));
        columns.Command(commands => commands.Custom("DeleteVideoCommand")
                                            .Text("Delete")
                                            .DataRouteValues(route => route.Add(o => o.VideoUID).RouteKey("videoId"))
                                            .Action("DeleteSelectedVideo", "Home"));
        columns.Command(commands => commands.Custom("ReplaceVideoCommand")
                                            .Text("Replace")
                                            .DataRouteValues(route => route.Add(o => o.VideoUID).RouteKey("videoId"))
                                            .Action("ReplaceSelectedVideo", "Home"));
    }).DataSource(dataSource => dataSource
    .Ajax()
    .Read(read => read.Action("VideoListRead", "Home"))
    ).Pageable().Sortable()
I have a Ajax bound grid and it is working fine when I do not have custom commands as part of my columns. If I use custom commands, I see an empty page 
and no grid is displayed. May be because of an error. Could you please let me know how to use custom commands on Ajax  bound grid.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 06 Aug 2013, 12:09 PM
Hi,

Custom route commands are available only for server binding. When using Ajax binding you should add a link in the column ClientTemplate e.g.

columns.Template(x => { }).ClientTemplate(
                "<a class='k-button' href='" +
                    Url.Action("EditSelectedVideo", "Home") +
                    "?videoId=#= VideoUID #'" +
                ">Edit</a>"
            );
Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
App Dev Tools
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or