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

Custom command action to a method, ajax binding.

0 Answers 190 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stefan
Top achievements
Rank 2
Stefan asked on 25 Sep 2012, 08:02 AM
How do i post a dynamic url to a method when using kendo grid with ajax bindings?

@(Html.Kendo().Grid(Model)
    .Name("Grid")
 
    .Columns(columns =>
    {

        columns.Bound(p => p.SalonName).Groupable(false);
        columns.Bound(p => p.ServiceName);
        columns.Bound(p => p.ResourceName);
        columns.Bound(p => p.StartDate).Format("{0: yyyy-MM-dd}").Title("Datum");
        columns.Bound(p => p.StartDate).Format("{0:hh:mm}").Title("Tid");
        columns.Bound(p => p.Duration);
        columns.Command(command => command.Custom("Detaljer").Click("BookingDetails"));
        columns.Command(command => command.Custom("Avboka").Click("confirmBookingRemoval"));
    })
     
    .Pageable()
    .Sortable()
    .Scrollable()
    .Selectable()
    .DataSource(dataSource => dataSource
        .Ajax()
                .Read(read => read.Action("ReadBookings", "Kund"))
                .ServerOperation(true)
                .PageSize(25))
                .Events(events => events.Change("grid_selected"))
)

<script type="text/javascript">
    function BookingDetails(arg) {
        var grid = $('#Grid').data('kendoGrid');
        var dataItem = this.dataItem($(arg.currentTarget).closest("tr"));
        var id = dataItem.AppointmentID;
        window.location.href = "@Url.Action("Detaljer", "@User.SalonKey/Boka")" + "/" + id;
        };
</script>

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Stefan
Top achievements
Rank 2
Share this question
or