i have comprehensive search that returns several lists of objects. Each such list is made of objects containing additional lists. The search is very complex in terms of processor load.
once i have the results, i display the original objects via partial view.
public ActionResult BeginSearch(SearchHomeVM searchParameters)
{
var search = new Search(searchParameters);
linije = search.PretraziLinije();
return PartialView("_searchResult", linije);
}
then in that form i wish to display details for a particular item via AJAX call. The problem is i need to use the objects data, not run another search in database. In razor i have:
@model LinijeSearchResult
@if (Model.BrojDirektnihLinija > 0)
{
<table id="direktneLinije" class="InvisibleTable">
<thead>
<tr>
<th>
Direktne linije
</th>
<th>
</th>
</tr>
</thead>
@for (int index = 0; index < Model.DirektneLinije.Count; index++)
{
LinijaSM item = Model.DirektneLinije[index];
List<LinijaSM> lin = new List<LinijaSM> { item };
<tr>
<td>@item.Naziv
</td>
<td>
@using (Ajax.BeginForm("RenderStanice",
new { psd = 0, index = index, lin = lin },
new AjaxOptions
{
HttpMethod = "POST",
UpdateTargetId = "staniceLinije",
InsertionMode = InsertionMode.Replace
}))
{
<input type="submit" value="Stanice" />
}
</td>
</tr>
}
</table>
}
else
{
<text>Nema direktnih linija za odabrane parametre.</text>
<br />
}
Here You can see how i am trying to pass the data to controller action that looks like this:
public ActionResult RenderStanice(List<LinijaSM> lin)
{
return PartialView("_staniceSR", lin);
}
In that controller action i get the empty list. can You please advise on how to accomplish this.
<< EDIT >>
up to this point i have figured out, that the List of any object can not be passed back to controller. the same goes for complex objects. I can pass a integer, but not a list of integers.
Can someone advise me on how to accomplish my goal? I need to pass a list of object back to controller. Can it be done by adding it to context, creating new viewData or something like that?
If that is not possible, can a partial view be rendered via through AJAX, but without a controller action?