This question is locked. New answers and comments are not allowed.
I have a dropdown and an mvc grid. When the Submit button is clicked it called a method passing in the value from the dropdown and populates a grid. The problem is when the sort or paging is clicked I cannot figure how to pass the value from the dropdown. The example shows no parameters being passed in the the grid filtering the results with a startswith (I don't want to do).
@using (Html.BeginForm("Filtering", "Home")){ <p> <label for="startsWith"> <strong>Contact Name</strong> starts with:</label> @Html.DropDownList("Classifications", ViewData["ClassificationItems"] as SelectList, new { style = "width:100px;" }) <button class="t-button t-state-default" type="submit"> Apply</button> </p> }@(Html.Telerik().Grid(Model) .Name("Home") .Columns(columns => { columns.Bound(o => o.CodeID).Width(120); columns.Bound(o => o.Title).Width(200); columns.Bound(o => o.Status); }) .DataBinding(dataBinding => dataBinding.Ajax().Select("_Filtering", "Home") .Sortable(sorting => sorting .SortMode(GridSortMode.SingleColumn) .AllowUnsort(true) .OrderBy(order => { order.Add(o => o.CodeID); }) ) .Pageable() )
Controller:
public ActionResult Filtering(string classifications = "")
{
ViewData["ClassificationItems"] = new SelectList(Classifications.List, "ClassificationText", "ClassificationText", classifications);
ViewData["SelectedCategory"] = classifications ?? "Type";
var codModels = new List<CodeModel>();
var model = _codeRepository.Search(classifications).ToModel();
return View(model);
}
[GridAction]
public ActionResult _Filtering(string selectedCategory = "")
{
return View(new GridModel<CodeModel>
{
Data = _codeRepository.Search(selectedCategory).ToModel()
});
}