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

[Solved] Filtering Grid Based On Button Click

1 Answer 1230 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rehan
Top achievements
Rank 1
Rehan asked on 06 Nov 2014, 03:01 PM
I have an Grid using paging and Ajax. I want to add a button, which when clicked causes the grid to be filtered. I added the code below:

$(function () {
    var grid = $("#grid").data("kendoGrid");
    var dataSource = grid.dataSource;
 
    var button = $("#myButton");
    button$("#myButton").click(function (e) {
        dataSource.filter(
            {
                "field": "Name",
                "operator": "eq",
                "value": "Bob Hoskins"
            });
    });
})

This causes the grid to make two calls to my Ajax resource. In the first call, the correct filter is passed and the grid briefly shows the correct filtering in the browser. Then a second call happens without my filter and the grid goes back to having no filters applied to it.

1 Answer, 1 is accepted

Sort by
-1
Daniel
Telerik team
answered on 10 Nov 2014, 12:20 PM
Hello,

The code looks correct and a single request should be made by the dataSource. Could you provide a runnable sample that replicates the issue or the full code that you are using so I can check the exact setup?

Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Rehan
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or