This is a migrated thread and some comments may be shown as answers.

[Solved] MVC Grid client filtering problem

2 Answers 154 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tetha
Top achievements
Rank 1
Tetha asked on 23 Jul 2011, 01:56 PM
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
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();
        }
    }

2 Answers, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 25 Jul 2011, 07:31 AM
Hello Mirko Pozzetti,

I'm afraid that setting the filter in such way when client operation mode is enabled is not currently supported. Also note that there is an issue with filter method which has been resolved and you may need to use the build provided in this thread.

All the best,
Rosen
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Tetha
Top achievements
Rank 1
answered on 25 Jul 2011, 10:40 AM
Hello Rosen,
thank you very much for your quick response.
I set grid in server mode with new binaries and now all works perfectly.
Thanks.
Mirko
Tags
Grid
Asked by
Tetha
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Tetha
Top achievements
Rank 1
Share this question
or