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

Passing object parameters to ajax select method

0 Answers 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
rino
Top achievements
Rank 1
rino asked on 10 Dec 2010, 01:45 AM

I have a View that contains input controls for a search function and Telerik grid for the search result. I am trying to pass an object to ajax select method (instead of an integer as described in this thead) when it is invoked (e.g. to sort).

Here is a snippet of my view. SearchScholar is a class.

<div class="editor-field">
<%: Html.TextBox("searchCriteria.FirstName", null, new { tabindex = "1" })%>
</div>
  
<!--additional code removed -->
  
<%= Html.Telerik().Grid(Model)
.Name("Search")
 .DataBinding(databinding =>
{
databinding.Ajax()
                      .Select("SearchAjax", "Scholar", 
                                  new {searchCriteria = (ScholarSearch)ViewData["searchCriteria"]})
                      .Enabled((bool)ViewData["ajaxEnabled"]);
 })               
.Sortable()
            %>

The controller looks like this
public ActionResult Search(ScholarSearch searchCriteria)
{
ViewData["searchCriteria"] = searchCriteria;
//code
return View(result)
}
  
[GridAction]
public ActionResult SearchAjax(ScholarSearch searchCriteria)
{
//code
return View(new GridModel(searchResult));
}

When SearchAjax is called, the parameter searchCriteria is always null.
Tags
Grid
Asked by
rino
Top achievements
Rank 1
Share this question
or