excel export and CustomBinding

10 posts, 0 answers
  1. Alan Mosley
    Alan Mosley avatar
    200 posts
    Member since:
    Apr 2010

    Posted 20 May 2015 Link to this post

    I just tried the excel export with custom binding, of cause I knew it would not get all data with custom binding, it only gets the current page.

    I can get the data myself if I could get the filter info, how to get filter info when using excel export?
    Thanks

  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 22 May 2015 Link to this post

    Hello Alan,

    The excel exporting will hit the Read() method of the grid's data source. If you set the AllPages option to true this will export all pages:

    @(Html.Kendo().Grid()
                 .Excel(excel => excel.AllPages(true))
    )

    Regards,
    Atanas Korchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Alan Mosley
    Alan Mosley avatar
    200 posts
    Member since:
    Apr 2010

    Posted 22 May 2015 in reply to Atanas Korchev Link to this post

    I am using custom binding, so it only outputs the page that is visible.
  5. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 25 May 2015 Link to this post

    Hi Alan,

    If you return only one page then the grid can't export all pages. You should check what the PageSize property of the DataSourceRequest parameter is and return the same amount of items. The grid will set the PageSize to the total number of items when exporting all pages.

    Regards,
    Atanas Korchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Alan Mosley
    Alan Mosley avatar
    200 posts
    Member since:
    Apr 2010

    Posted 25 May 2015 in reply to Atanas Korchev Link to this post

    That's would mean returning and rendering thousands of records, and if the user wants to sort or filter them before exporting that would be quite a bit of overhead.
    What I have done is save the DataSourceRequest in a session object and then use that in the export controller to get correct data, but I thought there would be a better way of getting that data in the export controller, eg: the export request sending filter and sort data to the controller. The workaround will do unless you can suggest a more elgant way of doing this, thanks
  7. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 25 May 2015 Link to this post

    Hello Alan,

    If you want to export all data you have to return it to the grid. If you want to apply some filter - you can distinguish the export read request by checking the PageSize of the DataSourceRequest parameter. 

    Regards,
    Atanas Korchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  8. Alan Mosley
    Alan Mosley avatar
    200 posts
    Member since:
    Apr 2010

    Posted 25 May 2015 in reply to Atanas Korchev Link to this post

    sorry I don't follow you. what do you mean by "distinguish the export read
    request"

     when exporting is the DataSourceRequest parameter sent to the server?

    Thanks

  9. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 25 May 2015 Link to this post

    Hi Alan,

    Yes, the grid will make a Read request in the case of Excel export and set the PageSize to the total number of items if you have set AllPages to true

    Regards,
    Atanas Korchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  10. Alan Mosley
    Alan Mosley avatar
    200 posts
    Member since:
    Apr 2010

    Posted 25 May 2015 in reply to Atanas Korchev Link to this post

    Just to make things clear, is the filter and sort info also sent? thanks
  11. Alan Mosley
    Alan Mosley avatar
    200 posts
    Member since:
    Apr 2010

    Posted 25 May 2015 in reply to Alan Mosley Link to this post

    Thanks, I am understanding better now, I did not realize that that both the read and export controllers were called, I was looking for DataSourceRequest object on export controller.

    Thanks all seems to be working fine now

Back to Top
UI for ASP.NET MVC is VS 2017 Ready