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

Redirect to Controller from Grid Command with row ID

0 Answers 271 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Charlie
Top achievements
Rank 1
Charlie asked on 23 Oct 2012, 03:50 PM
Hello,

I have looked through the forum a few times and not found something quite like what I am looking for.

I am using Kendo UI Complete with Razor syntax, but I am using VB,net

I have commands setup, and I want to redirect the user onclick to the same controller, but to its... say delete command, but I need to pass along the ID.

I get the circular reference issue when I use the DataSource field. Is there a way just to pass the ID (which I have hidden) along to the JS command to redirect the user?

Here is my view:

@ModelType IEnumerable(Of Core.Domain.MaintenanceTicket)
@Code
    ViewData("Title") = "Index"
    Layout = "~/Views/Shared/_Layout.vbhtml"
End Code
@section breadcrumb
Home > Maintenance Queue
End Section
<script type="text/javascript">
    $(document).ready(function () {
        $('li.q a').addClass("on");
    });
</script>
 
 
<h1>Maintenance Queue</h1>
<div class="row">
    <div class="box round twlevecol" style="font-size:12px;">
        @(Html.Kendo().Grid(Model) _
            .Name("MaintenanceTickets") _
                .Columns(Function(modelItem) modelItem.Bound(Function(p) p.Id).Hidden) _
                .Columns(Function(modelItem) modelItem.Bound(Function(p) p.CreateDate)) _
                .Columns(Function(modelItem) modelItem.Bound(Function(p) p.Originator)) _
                .Columns(Function(modelItem) modelItem.Bound(Function(p) p.CustomerName)) _
                .Columns(Function(modelItem) modelItem.Bound(Function(p) p.Description)) _
                .Columns(Function(modelItem) modelItem.Bound(Function(p) p.OntimeAssignedTo)) _
                .Columns(Function(modelItem) modelItem.Bound(Function(p) p.Description)) _
                .Columns(Function(modelItem) modelItem.Bound(Function(p) p.Priority.Name)) _
                .Columns(Function(modelItem) modelItem.Bound(Function(p) p.Status.Name)) _
                .Columns(Function(modelitem) modelitem.Command(Sub(p)
                                                                       p.Custom("Details").Click("showDetails").HtmlAttributes(New With {.class = "k-grid-btn"})
                                                                       p.Custom("Edit").Click("showEdit").HtmlAttributes(New With {.class = "k-grid-btn"})
                                                                       p.Custom("Delete").Click("showDelete").HtmlAttributes(New With {.class = "k-grid-btn"})
                                                               End Sub)) _
            .Pageable() _
            .DataSource(Function(dataSource) dataSource.Ajax().Read(Function(r) r.Action("CustomCommand_Read", "Ticket"))) _
            .Sortable() _
            .Filterable() _
            .Resizable(Function(resize) resize.Columns(True))
        )
    </div>
</div>
 
 
<script type="text/javascript">
    function showDetails(e) {
        e.preventDefault();
        var currentDataItem = $("#MaintenanceTickets").data("kendoGrid").dataItem($(e.currentTarget).closest("tr"));
        alert(currentDataItem);
     }
    function showEdit(e) { alert('Showing Edit Screen...'); }
    function showDelete(e) { alert('Showing Delete Screen...'); }
</script>

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Charlie
Top achievements
Rank 1
Share this question
or