@(Html.Kendo().Grid<
SearchViewModel
>()
.Name("searchGrid")
.Columns(columns =>
{
columns.Bound(x => x.ProductId);
columns.Bound(x => x.ProductName);
})
.AutoBind(false)
.DataSource(ds => ds
.Ajax()
.Read(read => read.Action("Search", "Product").Data("getSearchCriteria"))
)
)
)
function getSearchCriteria() {
var product = $("#ProductName").data("kendoAutoComplete").value();
var productType = $("#ProductType").data("kendoDropDownList").select();
if (product || productType) {
return { ProductName: product, ProductType: productType };
} else {
// TODO: Figure out how to cancel this request.
alert("You must provide at least one search parameter.");
return false;
}
}
Everything works great when search criteria is supplied. However, I can't find a way to cancel the request from the client side if no search criteria was supplied. Returning either "false" or "null" from the "getSearchCriteria" function has no effect.
Is there any way to tell the Kendo grid not to invoke the controller's action at this point in time?