Unplanned
Last Updated: 23 Apr 2020 13:21 by ADMIN
Auri
Created on: 17 Apr 2020 13:41
Category: Grid
Type: Bug Report
1
Kendo Grid from Table exports columns with zero width

Disclaimer: I'm running an older version of Kendo UI for jQuery, so this may have been fixed. I'd like confirmation if so before updating.

Kendo version: 2017.1.118.545

I am creating a grid from a table data source rather than an endpoint call. Other pages that use endpoints to populate the datasource export Excel with no problems.

Example HTML:

<table class="table table-responsive" id="tblReportSummary">
<colgroup>
<col />
<col />
<col />
<col />
<col />
</colgroup>
<thead>
<tr>
<th data-field="date">Date</th>
<th data-field="totalForStatus">Count</th>
</tr>
</thead>
<tbody>
@foreach (var item in ViewBag.ReportDataSummary as IEnumerable<UtilizationListViewModel>)
{
<tr>
<td>@item.Date</td>
<td>@item.TotalForStatus</td>
</tr>
}
</tbody>
</table>

The jQuery is as follows:

             $("#tblReportSummary").kendoGrid({
                sortable: true,
                toolbar: ["excel"],
                excel: {
                    allPages: true,
                    fileName: "Utilization Data Export.xlsx"
                },
                pageable: {
                    pageSize: 20,
                    pageSizes: [20, 50, 100]
                }
            });

When I click Export, all I get is an empty Excel file.

Why isn't the data there, please?

 

8 comments
ADMIN
Alex Hajigeorgieva
Posted on: 23 Apr 2020 13:21

Hello, Auri,

Yes, absolutely, since this is an inconsistency with the grids initialized from a div element, I logged it as a bug and added some Telerik points to your account

I have also moved this thread to our Public Feedback portal here:

https://feedback.telerik.com/kendo-jquery-ui/1462280-kendo-grid-from-table-exports-columns-with-zero-width

I will also update this post with the public GitHub issue if you prefer to follow it instead but GitHub seems to be down right now.

Regards,
Alex Hajigeorgieva
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Auri
Posted on: 21 Apr 2020 14:25
AHA! Thanks! I'll go check that out. Do you feel that Excel exports should default to some width so this doesn't cause confusion in the future? Perhaps a setting in the script for a defaultWidth?
ADMIN
Alex Hajigeorgieva
Posted on: 21 Apr 2020 13:59

Hi, Auri,

Thank you very much for the provided runnable example.

If you take a look closely at it, you will notice that the export is not empty but that the columns A and B have zero width. You can solve this by defining a width in the colgroup col:

https://dojo.telerik.com/@bubblemaster/oXANesUC

<colgroup>
 <col style="width:120px" />
 <col style="width:130px" />
</colgroup>

Alternatively, you may intercept the excelExport event and pass the column widths at that point:

            excelExport: function(e){
              var columns = e.workbook.sheets[0].columns;
              $.each(columns, function(i, col){                
                col.width = 100;
              })
            }

Kind Regards,
Alex Hajigeorgieva
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Auri
Posted on: 20 Apr 2020 20:47
Bump on this, please?
Auri
Posted on: 17 Apr 2020 15:01

I've updated the dojo with my HTML.

It doesn't work there, either, and the HTML looks fine.

Please give me a sanity check?

Thanks!

Auri
Posted on: 17 Apr 2020 14:52

I changed the scripts to the latest and I'm still having the issue.

The dojo works. My code doesn't. Using the same script in the dojo... The table looks fine.

Are there any gotchas I need to look out for with the table format, possibly?

Thanks and Best,

-Auri

Auri
Posted on: 17 Apr 2020 14:43

Nevermind, found the script to include.

It looks like this may be fixed with the latest release.

Thanks :)

Auri
Posted on: 17 Apr 2020 14:39

Follow up: I tried modifying a Dojo from the example page to replicate this with the latest bits. However, the dojo gave me an error that JSZip wasn't included... Any idea what I need to do there?

https://dojo.telerik.com/ULedEZIT