I have a pretty basic grid that is not populated on load. It requires users to enter search criteria first, which then searches the database and populates the grid. Below is the grid code
which used to work great but broke ever since i upgraded to the Kendo 924 version (and same problem since the 1002 as well) it doesn't work like it used to.
Basically i have 2 controller methods. The first (SearchChemBio) gets called when the user enters the search data and hits enter. data gets sent no problem and send a partialresult (which contains the grid). I have the ajax call in there in order to handle sorting/filtering/paging.
unfortunately now, the model in the Ajax call (_GetSearchResults) is always blank now (it didn't used to be before the update). Is there something i'm missing? I feel like i'm doing double work here, but can't figure out how to marry both calls.
Html.Kendo().Grid<
ArrayOfSearchResultObjectSearchResultObject
>(Model.Results)
.Name("srchGrd")
.Columns(columns =>
{
columns.Bound(o => o.Chemical).
ClientTemplate("<
a
title
=
'#=Chemical#'
href
=
'" + Url.Action("", "ChemBioSearch", new { area = "Tools" }, Request.Url.Scheme) + "/GetDetail?ChemName=#=Chemical#&DetailID=#=ID#&DetailSource=#=SearchSource#&id=" + Model.ProjectGUID.ToString() + "'
>" +
"#=Chemical# </
a
>"
).Title("Chemical");
columns.Bound(o => o.CasNumber).Title("CAS #");
columns.Bound(o => o.UnNumber).Title("UN ID #");
columns.Bound(o => o.FriendlySourceName).Title("Data Source");
})
.DataSource(ds =>
{
ds.Ajax().ServerOperation(false).Read(read => read.Action("_GetSearchResults", "ChemBioSearch", new { area = "Tools" }));
}
)
.Scrollable(scrolling => scrolling.Enabled(false))
.Sortable(sorting => sorting.Enabled(true))
.Pageable(paging => paging.Enabled(true))
.Filterable(filtering => filtering.Enabled(true))
.Groupable(grouping => grouping.Enabled(false))
.Render();
Basically i have 2 controller methods. The first (SearchChemBio) gets called when the user enters the search data and hits enter. data gets sent no problem and send a partialresult (which contains the grid). I have the ajax call in there in order to handle sorting/filtering/paging.
[AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
[OutputCache(NoStore =
true
, Duration = 0, VaryByParam =
"*"
)]
public
ActionResult _GetSearchResults([DataSourceRequest] DataSourceRequest request,ChemBioSearchModel mdl)
{
if
((mdl !=
null
) && (mdl.IsValid))
{
ArrayOfSearchResultObject rslt = SearchGlobal(mdl);
if
((rslt !=
null
) && (rslt.Items.Length > 0))
{
foreach
(ArrayOfSearchResultObjectSearchResultObject arr
in
rslt.Items)
{
mdl.Results.Add(arr);
}
}
return
Json(mdl.Results.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
return
Json(
new
List<ArrayOfSearchResultObjectSearchResultObject>().ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
[HttpPost]
[ValidateAntiForgeryToken]
public
ActionResult SearchChemBio(ChemBioSearchModel mdl
)
{
if
(mdl !=
null
)
{
if
(ModelState.IsValid)
{
ArrayOfSearchResultObject rslt = SearchGlobal(mdl);
if
((rslt !=
null
) && (rslt.Items !=
null
) && (rslt.Items.Length > 0))
{
foreach
(ArrayOfSearchResultObjectSearchResultObject arr
in
rslt.Items)
{
mdl.Results.Add(arr);
}
}
return
PartialView(
"SearchResults"
, mdl);
}
else
{
return
View(mdl);
}
}
throw
new
ArgumentException(
"No Model found for Chem Bio Search"
);
}