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

How to drop filters, sort column and paging in grid

8 Answers 327 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pavlik
Top achievements
Rank 1
Pavlik asked on 31 Oct 2012, 10:46 AM
Hi!

I want to clear, for example, the filter array in my grid:
$('table#user_org_table').data('kendoGrid').dataSource.filter({});

Filter is cleared, but after this .filter() function, my grid is automatically refreshed.
How to clear filter, sorting and paging with 1 time grid refreshing?

Thanks.

8 Answers, 1 is accepted

Sort by
0
Lee
Top achievements
Rank 1
answered on 21 Nov 2012, 03:57 PM
Ever figure this out? I'm interested, as well...
0
Pavlik
Top achievements
Rank 1
answered on 22 Nov 2012, 11:03 AM
// Clear filter/sort/page
$('table#user_org_table').data('kendoGrid').dataSource.query({
    page: 1,
    pageSize: 20,
    sort: {
        field: "SomeField",
        dir: "asc"
    },
    filter: [
        { field: "Search", value: "" },
        { field: "Status", value: "" }
    ]
});
So, use the ".query" method:)
0
Raj
Top achievements
Rank 1
answered on 12 May 2017, 05:12 PM

Hi Pavlik's

Did you get this working? Its not working for me when i passed empty arrays to sort and filter to clear all at a time.

0
Konstantin Dikov
Telerik team
answered on 17 May 2017, 10:11 AM
Hello Raj,

The filter and sort object could not contain an empty array, but if they are missing, the current expressions should be removed:
$("#grid").getKendoGrid().dataSource.query({page:1, pageSize: 20})

The above should clear all expression and should leave only the applied paging.


Regards,
Konstantin Dikov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Raj
Top achievements
Rank 1
answered on 17 May 2017, 02:15 PM

I tried your Code but thats not working as expected.

It is throwing error with empty sort and filter in the URL. please find attached Image.

Below is my code.

//clear grouping, sorting, filtering
            var datasource = $('#FacilityGrid').data('kendoGrid').dataSource;
           datasource.sort([])
           datasource.filter([])
           datasource.group([])

This works as expected but it is making three calls to controller. I want to clear all at a time.

With your Query    $("#FacilityGrid").getKendoGrid().dataSource.query({ page: 1 }); it is throwing error.
           

0
Boyan Dimitrov
Telerik team
answered on 22 May 2017, 12:32 PM

Hello Raj,

Please try to send the pageSize in the query method in order to work as expected. 

Regards,
Boyan Dimitrov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Raj
Top achievements
Rank 1
answered on 22 May 2017, 04:23 PM

Thanks for the fix. It works as expected.

But The number of records on footer are showing as NaN after executing that query.

please find attached image. How to fix that. I am using virtual scrolling.

Thanks

Raj.

0
Konstantin Dikov
Telerik team
answered on 25 May 2017, 08:36 AM
Hello Raj,

Could you please create a dojo example demonstrating the issue, so we could inspect it locally:
Looking forward to your reply.


Regards,
Konstantin Dikov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Pavlik
Top achievements
Rank 1
Answers by
Lee
Top achievements
Rank 1
Pavlik
Top achievements
Rank 1
Raj
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Boyan Dimitrov
Telerik team
Share this question
or