Get filtered data from paged grid

Thread is closed for posting
8 posts, 1 answers
  1. Zack
    Zack avatar
    112 posts
    Member since:
    Jun 2012

    Posted 29 May 2012 Link to this post

    What is a good way to get datasource results from a grid with paging and filtering applied and you want only the filtered out results?
    I see many people asking this kind of question but not many real thorough answers.
    datasource.data() gives you everything and datsource.view() gives you the current page you can see in the grid.

    Do you have to calculate total / pagesize and iterate for each page...?
  2. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2592 posts

    Posted 30 May 2012 Link to this post

    Hello Zack,

    I am not sure if I understand your question correctly, because the dataSource view() method returns a view of the result data from applied operation - such as paging and filtering.

    Could you please provide more details about the scenario your are trying to implement?
     

    Greetings,
    Iliana Nikolova
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Zack
    Zack avatar
    112 posts
    Member since:
    Jun 2012

    Posted 30 May 2012 Link to this post

    I have a grid with 3000 records in data source with a pageSize  of 5, that filtered shows 3 pages available and its count is 13 records.
    If I do a datasource.view() I get 5 records (current page 1 of 3, i guess).
    If I do a datasource.data() I get 3000 records.
    I want to get 13 records (filtered results, ignoring paging).
  5. Answer
    Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2592 posts

    Posted 31 May 2012 Link to this post

    Hello Zack,

    Such functionality is not supported out of the box, because the Kendo UI Grid widget displays the current view of the data. Hence when the grid paging is enabled and you filter the grid you are able to get only the data from  the current page, i.e. the current view.

    In order to get all the filtered data when the grid is page-able you need to implement a custom logic for manipulation of the dataSource independently from the grid. The approach I would suggest is to get all the data and the applied filters from the dataSource. Then using a separate Query to get the whole filtered data. For example:
    var dataSource = $("#grid").data("kendoGrid").dataSource;
    var filters = dataSource.filter();
    var allData = dataSource.data();
    var query = new kendo.data.Query(allData);
    var data = query.filter(filters).data;

    I hope this helps.  
       
    Regards,
    Iliana Nikolova
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Oskar
    Oskar avatar
    12 posts
    Member since:
    Sep 2011

    Posted 31 May 2012 Link to this post

    Hi guys,

    I was wandering about the same thing. What I did, was extending DataSource with my custom 'view' method. It switched off all on 'change' callbacks, set page size for 'total' number of items, got filtered data, set page size for old page size, then set old callbacks on.

    But due to new changes in Kendo is not working anymore. It would be nice to have such function to obtain filtred/grouped/ordered data without paging.

    Cheers,
    Oskar.
  7. Zack
    Zack avatar
    112 posts
    Member since:
    Jun 2012

    Posted 31 May 2012 Link to this post

    Yes, thank you Iliana that is perfect! I never tried the query method.
  8. James Boman (IPMO)
    James Boman (IPMO) avatar
    4 posts
    Member since:
    Nov 2014

    Posted 16 Mar 2015 in reply to Iliana Nikolova Link to this post

    Iliana Nikolova said:
    In order to get all the filtered data when the grid is page-able you need to implement a custom logic for manipulation of the dataSource independently from the grid. The approach I would suggest is to get all the data and the applied filters from the dataSource. Then using a separate Query to get the whole filtered data. For example:
    var dataSource = $("#grid").data("kendoGrid").dataSource;
    var filters = dataSource.filter();
    var allData = dataSource.data();
    var query = new kendo.data.Query(allData);
    var data = query.filter(filters).data;


    Iliana,
        Unfortunately this doesn't work and only ever provides the data from the first page - could you please provide a working example?

    Here is what I am talking about:  http://dojo.telerik.com/@JBoman32768/EKUGe

    Filter the results in the grid to yield more than one page of data, then press the button.  I only ever get the results for the first page :(

    Cheers,
       James.
  9. James Boman (IPMO)
    James Boman (IPMO) avatar
    4 posts
    Member since:
    Nov 2014

    Posted 16 Mar 2015 in reply to James Boman (IPMO) Link to this post

    Never mind - I figured it out myself

    http://dojo.telerik.com/@JBoman32768/Ucudi

    Cheers,
       James.
Back to Top
Kendo UI is VS 2017 Ready