Excel Export not working correctly after datasource refreshing data

6 posts, 0 answers
  1. reader
    reader avatar
    7 posts
    Member since:
    Jan 2015

    Posted 06 Feb 2015 Link to this post

    I have a Grid, when users click a button, it gets some parameters and refresh datasource:

    var grdUP = $("#weblogGrid").data("kendoGrid");
    grdUP.dataSource.transport.options.read.url = url; // new url
     
    //Read data source to update
    grdUP.dataSource.read();

    it works fine. the new data shows in the grid. And the grid has another button, which will export the data to excel. I'm using below code (also tried the built-in button):
    var grid = $("#weblogGrid").data("kendoGrid");
    grid.saveAsExcel();

    it actually exports the data to excel file. 

    However, it always exports the initial data in the grid, not the data user refreshed.

    For example, when the grid first shows up, it has 10 rows data. After refresh, it has 5 rows data. Now, if export, it still exports 10 rows data although the data in grid is different.

    Is this a Bug? or, maybe I did something wrong in refresh grid?


    Thanks


  2. reader
    reader avatar
    7 posts
    Member since:
    Jan 2015

    Posted 09 Feb 2015 in reply to reader Link to this post

    Anyone has a solution for this? So basically, export will export data that is initialized in the first time. dataSource.read() will affect the grid, we can see the new results, but it does not affect the export. Is it because the initialized data cached somewhere and not updated when it reads new data?

    what's the correct way to update the dataSource for the grid?

    I'm sure many users will have this case, nobody had the issue?

    Thanks


  3. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2596 posts

    Posted 10 Feb 2015 Link to this post

    Hello,

     

    You have two options to resolve this issue:

     

    1. Set the transport.read.url option to a function that is dynamically resolved when needed, as setting the url with options.read.url = url is not supported. Here is the documentation about it:

    http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-transport.read.url

     

    2. You can create a new dataSource with the new url, and then use the setDataSource() method of the grid to change the dataSource. Here is the documentation about it:

     

    http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#methods-setDataSource

     

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  4. yaron
    yaron avatar
    3 posts
    Member since:
    Feb 2015

    Posted 09 May 2016 in reply to Kiril Nikolov Link to this post

    Same problam here

    i tryied your two option , none worked.

    any idea ?

  5. yaron
    yaron avatar
    3 posts
    Member since:
    Feb 2015

    Posted 09 May 2016 Link to this post

    found the solution !
    after refreshing the data source with new parameters,
    you should set the filter option on the dataSource with the new params.

    for example i refresh the data like this :

    grid.dataSource.filter(newfilters);

    i add the next row of code to solve the problam :

    grid.dataSource.options.filter=newfilters;

  6. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2596 posts

    Posted 09 May 2016 Link to this post

    Hello,

    I am happy to hear that you found a solution for this.

    In case you have any further questions - please open a separate support request and we will be happy to help.

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top