This question is locked. New answers and comments are not allowed.
Hi,
I have a MVC Grid and I want to enable client filtering.
I create a button binded to applyFilter function, but when the function is executed nothing appens on the grid.
When I use embedded filtering all works like a charm.
Below the code, View and Controller (very simple).
Thanks you in advance.
Mirko
I have a MVC Grid and I want to enable client filtering.
I create a button binded to applyFilter function, but when the function is executed nothing appens on the grid.
When I use embedded filtering all works like a charm.
Below the code, View and Controller (very simple).
Thanks you in advance.
Mirko
VIEW
<input type="button" name="Cerca" value="Cerca" onclick='applyFilter();' />@(Html.Telerik().Grid<Annuncio>() .Name("GridAnnunci") .Columns(columns => { columns.Bound(o => o.ImmaginePrincipale).Width(90) .ClientTemplate("<img height='60px' width='80px' alt='' src='" + Url.Content("~/imgimmobili/") + "<#= ImmaginePrincipale #>' />") .Sortable(false) .Title(string.Empty); columns.Bound(o => o.Agenzia); columns.Bound(o => o.Codice); columns.Bound(o => o.Tipo); columns.Bound(o => o.Comune); columns.Bound(o => o.Provincia); columns.Bound(o => o.Mq); columns.Bound(o => o.Prezzo).Format("{0:c}"); }) .DataBinding(dataBinding => dataBinding.Ajax().OperationMode(GridOperationMode.Client).Select("GetImmobili","Home")) .Pageable(paging => paging.PageSize(6).Enabled(true)) .Filterable() .Sortable())<script type="text/javascript"> function applyFilter() { var grid = $('#GridAnnunci').data('tGrid'); grid.filter("Codice~eq~'C500'"); }</script>
CONTROLLER
public class HomeController : Controller
{
private RealEstateContext db = new RealEstateContext();
public ActionResult Index()
{
var annunci = db.SlideAnnunci.OrderBy(a => a.Codice);
return View(annunci);
}
[GridAction]
public ActionResult GetImmobili()
{
return View(new GridModel<Annuncio>
{
Data = db.Annunci
});
}
public ActionResult About()
{
return View();
}
}