While Kendo Grid development (using HTML Razor syntax , MVC, Jquery and JavaScript) if my filters are empty I don't want to call the controller or Read the data. How I can do that? here is my code snippet Razor Code snippet--
Read(read => read.Action("Action", "Controller").Data("getFilters"))
JSCode
getFilters= function (e)
{
if (e.filter === null)
//do nothing and stop
else
return { filters }
}
Help appreciated.
Thanks in advance.
You could stop the request in the DataSource's RequestStart
event:
function requestStart(e) {
if (!this.filter()) {
e.preventDefault();
}
}
You might want to extend this snippet to inform the user that no new data were loaded due to the empty filter. Otherwise the user might be confused why the result did not change if he submits an empty filter.