Kendo Grid SaveAsExcel no data

4 posts, 1 answers
  1. Alain
    Alain avatar
    8 posts
    Member since:
    Mar 2012

    Posted 23 Mar 2017 Link to this post

    Hey everyone.  I have a main grid which saves pdfs and excel files just fine, but another grid which i have inside of a kendo window returned from a partial view does not.  However the pdf export works just fine, whereas the excel export only shows the headers.

    The only difference I can see is that my second grid has no read method, but rather has its contents returned from an ajax call.

    Sample code for popup:

    function openQuarterlyGrid(params) {
         (...)
            var data = {
                (...)
            };

            // get the view, load content to kendo window
            $.ajax({
                type: 'POST',
                url: '@Url.Action("ReadQuarterlyGrid", "Grid")',
                data: data,
                datatype: "html",
                success: function (e) {
                    wnd.setOptions({
                        title: '',
                        height: '600',
                        width: '868', 
                        modal: true
                    });

                    // open and center window
                    wnd.open().center();
                    //  set the window content
                    wnd.content(e);
                },
                error: function () {
        (...)
                },
                complete: function (xhr, status) {
                    (...)
                }
            });
        }

    controller method:

     [HttpPost]
            public ActionResult ReadQuarterlyGrid(...){

    (...)

    return PartialView("Grids/QuarterlyGrid", model);

    }

     

  2. Alain
    Alain avatar
    8 posts
    Member since:
    Mar 2012

    Posted 23 Mar 2017 in reply to Alain Link to this post

    And the actual grid:

     

    @(Html.Kendo().Grid(Model.QuarterlyReportGridValues)
            .Name("QuarterlyReportGrid")
            ...     
            .Columns(columns =>
            {
                columns.Bound(

    (...)
            })
            .ClientDetailTemplateId(...)
            .Events(e => e.DataBound(...)

    .DetailInit(...)

    .ExcelExport("onQuarterlyGridExcelExport"))
            .Sortable()
            .Excel(xls => xls.FileName("Quarterly Report.xlsx").AllPages(true))
            .Pdf(pdf => pdf.FileName("Quarterly Report.pdf").AllPages())
            .DataSource(dataSource => dataSource
                .Ajax()            
                .Model(model =>
                {
                  (...)
                })
                .Group(  
                .Events(events =>
                {
                    events.RequestEnd(...)  
                    events.Error("onError");
                })
            )
        )

  3. Answer
    Viktor Tachev
    Admin
    Viktor Tachev avatar
    2469 posts

    Posted 27 Mar 2017 Link to this post

    Hi Alain,

    I have examined the provided code and noticed that you have configured the Grid to use Ajax binding. Note that in this scenario you should specify a Read() method in order for the component to work as expected.


    In case you would like to use Server binding for the Grid you can use the approach illustrated below.



    Note that mixing the two approaches is not recommended and can result in unexpected behavior.


    Regards,
    Viktor Tachev
    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.
  4. Alain
    Alain avatar
    8 posts
    Member since:
    Mar 2012

    Posted 28 Mar 2017 in reply to Viktor Tachev Link to this post

    Yup, that was it.  I rewrote all my detail grid code to use the regular ajax/read method and it worked.  Much appreciated.
Back to Top