This is a migrated thread and some comments may be shown as answers.

Kendo Grid SaveAsExcel no data

3 Answers 469 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alain
Top achievements
Rank 1
Alain asked on 23 Mar 2017, 07:46 PM

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);

}

 

3 Answers, 1 is accepted

Sort by
0
Alain
Top achievements
Rank 1
answered on 23 Mar 2017, 07:51 PM

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");
            })
        )
    )

0
Accepted
Viktor Tachev
Telerik team
answered on 27 Mar 2017, 02:29 PM
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.
0
Alain
Top achievements
Rank 1
answered on 28 Mar 2017, 06:53 PM
Yup, that was it.  I rewrote all my detail grid code to use the regular ajax/read method and it worked.  Much appreciated.
Tags
Grid
Asked by
Alain
Top achievements
Rank 1
Answers by
Alain
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or