In my mvc project i have a simple list of items with crud operations like this:
<tbody>
@{
foreach (var item in Model)
{
<tr>
<td>@item.Title</td>
<td>@item.Body</td>
<td>@item.Price</td>
<td><span class="EditLink ButtonLink" noteid="@item.Id">Edit</span> | <span>@Html.ActionLink("Delete", "Delete", new { id = @item.Id})</span>
| @Html.ActionLink("Detalji", "Details", new { id = @item.Id})
</td>
</tr>
}
}
</tbody>
I am wondering is it possible to render details view as partial under the table when i click on details. I mean when i clik details to show me details view, i want it under my table in some div or paragraph.
Please help.
may not be the answer you are looking for...
you can do an ajax call
onClick
ofdetails
link and append the response to some div,for example
controller side
in your markup define a
div
that will hold the response of ajax callYou could use AJAX. But first let's improve your code by getting rid of those loops and replacing them with display templates:
and then define a display template (
~/Views/Shared/DisplayTemplates/SomeViewModel.cshtml
):Now all that's left is to AJAXify this details link in a separate javascript file:
Which assumes of course that you have the following action:
Yes. It's possible. Preferably, you should render the details in ajax. Because you will not need to render all the details for each row. And user will need to click on the details.