I have gone back and forth trying to track down an Excel export problem I have but to no avail. I have a page which loads a tabstrip and creates tabs dynamically based on data stored in an odata list - retrieved using a kendo datasource and I then loop through the data to create the tabs and populate the tabs with a grid each of which is connected to an odata source. Each grid has an export to excel toolbar button with specific export code to reformat parts of the export to replace footertemplate <span> tags to output totals in bold and things like that but whichever grid I press the export button on, it always exports the grid from the last tab. I've even added specific buttons on to each tab above the grid and made the code on the button click event call an onClick function to do the following:
function onClick(e) {
var grid = '#' + e.event.target.id.replace('btnExcelExport', '').toLowerCase() + 'grid';
$(grid).data("kendoGrid").saveAsExcel();
return false;
}
I added an alert into the function above to display the "grid" variable and the name is correct but in each case it still exports the data from the grid on the last tab. I have checked the page carefully and each grid has a unique id so it's not an issue with that. Just in case it matters the export code in the grid is as follows:
excelExport: function (e) {
var sheet = e.workbook.sheets[0];
var cellValue = '';
for (var rowIndex = 0; rowIndex <
sheet.rows.length
; rowIndex++) {
var
row
=
sheet
.rows[rowIndex];
for (var
i
=
0
; i < row.cells.length; i++) {
cellValue
=
row
.cells[i].value;
if (cellValue === undefined) { }
else {
if (typeof cellValue === 'string') {
if (cellValue.indexOf("float:right") != -1) {
row.cells[i]
.value
=
cellValue
.replace("<span
class
=
'boldFont'
style
=
'float:right;'
>", "").replace("</
span
>", "");
row.cells[i].hAlign = "right";
row.cells[i].bold = true;
}
else if (cellValue.indexOf("boldFont") != -1) {
row.cells[i].value = cellValue.replace("<
span
class
=
'boldFont'
>", "").replace("</
span
>", "");
row.cells[i].bold = true;
}
}
}
}
}
}
Any advice or suggestions?