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

Client-side filtering with server-side binding?

1 Answer 75 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.
Basem
Top achievements
Rank 1
Basem asked on 26 Apr 2012, 08:54 AM
I am trying to use the client-side API to filter a grid, but it is not doing anything at all. There are no Javascript errors either even though my breakpoint hits it in Firebug. Everything else works on the client-side even the sorting and filter headers, but my button click is not doing anything. Am I doing anything wrong here?

@(Html.Telerik().Grid(Model)
    .Name("RouteGrid")
    .Columns(columns =>
    {
        columns.Bound(r => r.RouteId).Title("Route #");
        columns.Bound(r => r.LongName).Title("Route:");
        columns.Bound(r => r.Description).Title("Description");
    })
    .ToolBar(toolBar => toolBar.Template(
        @<text>
            <input type="text" id="routes_search" />
            <input type="submit" id="routes_submit" value="" />
        </text>))
    .DataBinding(dataBinding => dataBinding.Ajax()
        .OperationMode(GridOperationMode.Client)
        .Select("GridAjax", "Routes"))
    .Sortable()
    .Filterable()
)
 
<script type="text/javascript">
    $(function() {
        $('#routes_submit').click(function(e) {
            var grid = $('#RouteGrid').data('tGrid');
            grid.filter("LongName~substringof~'" + $('#routes_search').val() + "'");
        });
    });
</script>

    public class RoutesController : Controller
    {
        public ActionResult Grid(string view)
        {
            return View(this.GetRoutes());
        }
 
        [GridAction]
        public ActionResult GridAjax()
        {
            return View(new GridModel(this.GetRoutes()));
        }
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 26 Apr 2012, 03:19 PM
Hello Basem,

The problem is that the client filter() method is currently not supported in client operation mode. However, this can be workaround to a degree by manually parsing the filter expression and assigning it to the DataSource component of the grid. I have attached a modified version of a Code Library which covers similar to your scenario (using the ClientOperationMode).
I hope this helps.

Kind regards,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
Tags
Grid
Asked by
Basem
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or