angular - 无法以角度 6 导出到剑道网格中的 excel 整个网格数据
问题描述
嗨,我正在尝试以角度使用剑道网格的导出到 excel 功能以下是我的 html 代码
HTML
<button type="button" kendoGridExcelCommand icon="file-excel">Export to Excel</button>
<kendo-grid-excel fileName="Categories.xlsx" [fetchData]="allData">
</kendo-grid-excel>
打字稿
class {public gridData:any[];public allData(): ExcelExportData {
const result: ExcelExportData = {
data: process(this.gridData, {
sort: [{
field: 'RequestNumber',
dir: 'asc'
}]
}).data,
};
return result;
}
error :Cannot read property 'gridData' of undefined
参考这篇文章剑道出口
解决方案
“kendo-grid-excel”组件需要在 Grid 组件中,并且“this”对象应该指向“allData”方法中的实际组件——或者在构造函数中绑定它:
constructor() {
this.allData = this.allData.bind(this);
}
...或使用箭头功能:
public allData = () => {
// "this" will be the expected object here
}
推荐阅读
- go - 如何检查时间是否包含毫秒
- jquery - 如何通过以下方式创建 JSON 结构
- java - 为什么只有特定情况才需要在方法签名中抛出 IOException?
- c# - 所有平台是否有一种语法可以使用存储在 uno 跨平台库项目中的 .resw 文件中的本地化资源
- python - 获取:尝试读取文本文件时出现索引超出列表错误
- python - Python 3.8 - list.append('█') 但不适用于空格字符?
- python - pygame 不适用于 Visual Studio 代码(我使用的是 mac os catalina)
- crystal-reports - Crystal Reports:来自 distinctcount 的不同结果
- cross-compiling - Buildroot多个输出目录?
- redis - Redis HashScanAsync 不再可用