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

Invoking controller action passing model property

1 Answer 174 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shailendra
Top achievements
Rank 1
Shailendra asked on 25 Sep 2015, 07:17 AM

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.

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 29 Sep 2015, 10:41 AM

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. 

 

Regards,
Boyan Dimitrov
Telerik
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
Tags
Grid
Asked by
Shailendra
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or