Excel Export AllPages(true) issue

7 posts, 0 answers
  1. Craig
    Craig avatar
    11 posts
    Member since:
    Sep 2017

    Posted 17 Jan 2018 Link to this post

    Greetings - looking for a little help.

    When I use ExcelExport.AllPages(false) everything works great and I get a download. However when I use AllPages(true) it doesn't do anything - no console errors - just no results. I can simply switch it back to false and works again so it has to be something with that setting. Here's a portion of my settings let me know if you meed more.

    .DataSource(dataSource => dataSource

                .Ajax()
                .PageSize(20)
                .Read(read => read.Action("GetOrders", "SalesOrder").Data("toolbarValue"))
                .Sort(sort => sort.Add("LastChanged").Descending())
                .Events(e => e.Error("onError")))
            .Excel(excel => excel
                .FileName("soexport.xlsx")
                .ProxyURL(Url.Action("ExcelExport", "SalesOrder"))
                .AllPages(false))

    Thanks!

    Craig

  2. Stefan
    Admin
    Stefan avatar
    2491 posts

    Posted 19 Jan 2018 Link to this post

    Hello, Craig,

    Thank you for the provided code.

    I noticed that the Grid is with server operations(default for the MVC version). I can suggest inspecting the network tab to observe if the Grid has made any requests to the server when the export button is clicked and if these responses contain any data.

    If the response does not contain data, please debug the server-side logic to determine why the requests are empty.

    If the responses contain the data, and the document is still empty, please share with us an example, as there is maybe a factor which we are overlooking at this moment.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Craig
    Craig avatar
    11 posts
    Member since:
    Sep 2017

    Posted 19 Jan 2018 in reply to Stefan Link to this post

    Thanks Stefan - I will look again but I was checking that. There is a breakpoint on the server side in the first line of code. When that AllPages(false) is set it hits it else it's not even called. It's really strange. Just by switching false to true causes a huge change. Not sure what to do. I'll inspect some more and report back but I don't think there's much more I can do.

    Thanks!

    Craig

  4. Craig
    Craig avatar
    11 posts
    Member since:
    Sep 2017

    Posted 19 Jan 2018 in reply to Stefan Link to this post

    Hey Stefan - just an additional note. I did some more thorough checking on this and after setting it to true it indeed doesn't reach the server side code, with false it does. No errors or anything to go on. So any ideas you have would be great. Also if there is a way I can do this client side instead I would be up for switching it - if so can you please let me know how to do that.

    Thanks!

    Craig

  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 23 Jan 2018 Link to this post

    Hi Craig,

    Could you please share the entire configuration of the Grid, so we can see what could be causing the unexpected behavior on your side? 

    Meanwhile you can take a look at our documentation for the Excel Export and see if what differs in your configuration: 
    Looking forward to your reply.
     

    Regards,
    Konstantin Dikov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. Craig
    Craig avatar
    11 posts
    Member since:
    Sep 2017

    Posted 23 Jan 2018 in reply to Konstantin Dikov Link to this post

    Hi Konstantin - appreciate the help!

    Full settings are below. Here's a few things I've noticed since last time:

    - I removed the proxy call out to the server. Noticed it's really not needed, it exports fine without it. However changing AllPages from false to true still has the same exact issue. False works great trues does not with no other changes

    - When it it set to AllPages(True) there is nothing generated in the console at all, I don't see anything coming out

    - Could I combine your default excel button setup with my custom tool bar template? Wondering if that will help. I'm wondering if it has something to do with how the excel button is configured in the tool bar custom template possibly? 

    Here's the settings:

    @(Html.Kendo().Grid<SalesOrderSearchResultsViewModel>()
            .Name("Grid")
            .Columns(columns =>
            {
                columns.Bound(o => o.WarehouseOrderNumber).Title("SO Number").Width(150);
                columns.Command(command => command.Custom("Tracking").Click("getTracking")).Width(100);
                columns.Command(command => command.Custom("Serials").Click("getSerials")).Width(100);
                columns.Bound(o => o.PONumber).Width(150);
                columns.Bound(o => o.EndUserPO).Width(150);
                columns.Bound(o => o.Status).Filterable(f => f.Extra(false).UI("statusFilter").Operators(o=>o.ForString(s=>s.Clear().Contains("Contains")))).Width(100);
                columns.Bound(o => o.DocTypeDesc).Width(150);
                columns.Bound(o => o.ShippingAddress.Name).Title("ShipTo Name").Width(150);
                columns.Bound(o => o.ShippingAddress.City).Width(150);
                columns.Bound(o => o.ShippingAddress.PostalCode).Width(130);
                columns.Bound(o => o.Total).Format("{0:c}").Width(100);
                columns.Bound(o => o.DateEntered).Title("Entered").Format("{0:MM/dd/yyyy}").Width(110);
                columns.Bound(o => o.LastChanged).Title("Changed").Format("{0:MM/dd/yyyy}").Width(110);
                columns.Command(command => command.Custom("Details").Click("getDetails")).Width(100);
            })
            .ToolBar(toolbar => toolbar.ClientTemplate("<text><div class='toolbar'><a role='button' class='k-button k-button-icontext k-grid-excel' href='test'><span class='k-icon k-i-file-excel'></span>Export to Excel</a><span class='core-lbl'>Search: </span><input type='text' name='search' class='k-textbox' id='toolBarInput'/><span class='core-lbl'>Type: </span><input id='searchType' style='width:200px' /><span class='core-lbl'>Start Date: </span> <input id='dpStartDate' title='Start Date' style='width: 130px' /> <span class='core-lbl'>End Date: </span><input id='dpEndDate' title='End Date' style='width: 130px;' />  <button class='k-button' onclick='search()'>Search</button></div></text>"))
            .Sortable()
            .Pageable(p => p.ButtonCount(5).PageSizes(new int[] { 20, 50, 100, 1000, 2000 }).Refresh(true))
            .Filterable()
            .Resizable(r => r.Columns(true))
            .ClientDetailTemplateId("template")
            .Scrollable(scr => scr.Height(800))
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(20)
                .Read(read => read.Action("GetOrders", "SalesOrder").Data("toolbarValue"))
                .Sort(sort => sort.Add("LastChanged").Descending())
                .Events(e => e.Error("onError")))
            .Excel(excel => excel
                .FileName("soexport.xlsx")
                //.ProxyURL(Url.Action("ExcelExport", "SalesOrder"))
                .AllPages(true))
            .Events(events => events
                .DataBound("onDataBound"))
        )

     

    Thanks again!

    Craig

  7. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 25 Jan 2018 Link to this post

    Hello Craig,

    It is possible that the response exceeds the maxJsonLength if you have too many records in the database:
    Note that when you set AllPages to true, the Grid will make a request to retrieve all records, which with huge amount of records could cause the above issue. You can see if that is the case by inspecting the Network tab and see if the request fails and if it initiated at all.

    Please note that the toolbar is configured correctly and I have tested it locally with the following Grid configuration and everything works as expected:
    @(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.ProductViewModel>()
        .Name("grid")
     
        .Columns(columns =>
        {
            columns.Bound(p => p.ProductName).Width(300)
                   .ClientFooterTemplate("Total Count: #=count#")
                   .ClientGroupFooterTemplate("Count: #=count#");
            columns.Bound(p => p.UnitPrice).Width(300);
            columns.Bound(p => p.UnitsOnOrder).Width(300)
                   .ClientFooterTemplate("Average: #=average#")
                   .ClientGroupFooterTemplate("Average: #=average#");
            columns.Bound(p => p.UnitsInStock).Width(300)
                   .ClientFooterTemplate("Min: #= min # Max: #= max #")
                   .ClientGroupHeaderTemplate("Units In Stock: #= value # (Count: #= count#)");
        })
        .ToolBar(toolbar => toolbar.ClientTemplate("<text><div class='toolbar'><a role='button' class='k-button k-button-icontext k-grid-excel' href='test'><span class='k-icon k-i-file-excel'></span>Export to Excel</a><span class='core-lbl'>Search: </span><input type='text' name='search' class='k-textbox' id='toolBarInput'/><span class='core-lbl'>Type: </span><input id='searchType' style='width:200px' /><span class='core-lbl'>Start Date: </span> <input id='dpStartDate' title='Start Date' style='width: 130px' /> <span class='core-lbl'>End Date: </span><input id='dpEndDate' title='End Date' style='width: 130px;' />  <button class='k-button' onclick='search()'>Search</button></div></text>"))
        .Pageable()
        .Sortable()
        .Scrollable()
        .Groupable()
        .Excel(excel => excel
            .FileName("Kendo UI Grid Export.xlsx")
            .Filterable(true)
            .AllPages(true)
        )
        .Reorderable(r => r.Columns(true))
        .Resizable(r => r.Columns(true))
        .ColumnMenu()
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(7)
            .Group(g => g.Add(p => p.UnitsInStock))
            .Aggregates(aggregates =>
            {
                aggregates.Add(p => p.UnitsInStock).Min().Max().Count();
                aggregates.Add(p => p.UnitsOnOrder).Average();
                aggregates.Add(p => p.ProductName).Count();
                aggregates.Add(p => p.UnitPrice).Sum();
            })
            .Read(read => read.Action("Excel_Export_Read", "Grid"))
        )
    )

    One thing that I could suggest at this point is to share the code of the Data function of your read and the code within the DataBound event.


    Regards,
    Konstantin Dikov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top