Invoking controller action passing model property

2 posts, 0 answers
  1. Shailendra
    Shailendra avatar
    3 posts
    Member since:
    Feb 2014

    Posted 25 Sep 2015 Link to this post

    Assuming I have the below table:

    @Html.Kendo().Grid(Model).Name("Staff").Columns(x =>{         x.Bound(y => y.StaffId);         x.Bound(y => y.FirstName);         x.Bound(y => y.LastName);         x.Bound(y => y.Email);         x.Bound(y => y.Phone);         x.Command(y => y.Custom("Edit").Action("edit", "controller", new { id = ????? }));}).Sortable().Scrollable().Pageable(x=> x.PageSizes(true)).Filterable()


    How can I pass the primary key value (StaffId in this case) associated to the row to the object route values similar to the way it is done by Visual Studio auto-scaffold? I do not want a Java Script based solution. I am just looking for a way to pass the current row id (PK) to server action. Is it possible?

    For more information please refer this SO thread.

  2. Boyan Dimitrov
    Boyan Dimitrov avatar
    1728 posts

    Posted 29 Sep 2015 Link to this post

    Hello Shailendra,


    I would like to clarify that Action method for the command should be used only for server-binding grid.


    However at my side the URL generated for the custom edit command button includes the model id value (ProductID in this case). What I mean is that the href of the <a> element is :


    <a class="k-button k-button-icontext k-grid-Edit" href="/controller/edit?ProductID=3"><span></span>Edit</a>


    Please refer to the sample project attached to this response. 


    Boyan Dimitrov
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET AJAX banner
Back to Top