剑道网格Excel导出,带下拉模板的列
我想将剑道网格数据导出到excel中。我使用剑道下拉列表作为一些列的模板 当我导出时,它会导出,但不会显示这些列的文本值,而是显示这些字段的值。这可能不是“最佳”解决方案,但它对我有效。基本上,我创建了一个函数,通过下拉菜单循环并处理行,使用switch语句根据值设置文本(不幸的是,通过的数据只有值,而不是对象) 以下是我的网格的标记:剑道网格Excel导出,带下拉模板的列,excel,templates,kendo-grid,export-to-excel,Excel,Templates,Kendo Grid,Export To Excel,我想将剑道网格数据导出到excel中。我使用剑道下拉列表作为一些列的模板 当我导出时,它会导出,但不会显示这些列的文本值,而是显示这些字段的值。这可能不是“最佳”解决方案,但它对我有效。基本上,我创建了一个函数,通过下拉菜单循环并处理行,使用switch语句根据值设置文本(不幸的是,通过的数据只有值,而不是对象) 以下是我的网格的标记: <div id="grid" data-role="grid" data-sortable=" {mode: 'single' , allowunsort
<div id="grid" data-role="grid"
data-sortable=" {mode: 'single' , allowunsort:true }"
data-toolbar="[{template: this.model.getToolbar}]"
data-excel="{ fileName: 'export.xlsx', allPages:'true' }"
data-excel-export="model.curateExcelData"
data-columns="@string.Format(@"[
{{ title:'{0}', field: 'Column1', width:80 }},
{{ title:'{1}', field: 'Column2', width:80 }},
{{ title:'{12}', field: 'DropDownColumn',template: kendo.template($('#dropdown-template').html()),'width':80, sortable: false }},
]", CommonResource.Column1, CommonResource.Column2, CommonResource.DropDownColumn)"
data-bind="source: items"
data-editable="inline">
</div>
<script id="dropdown-template" type="text/x-kendo-template">
<input data-role="dropdownlist"
data-auto-bind="false"
data-value-primitive="true"
data-text-field="Text"
data-value-field="Value"
data-bind="value: dropDownValue, source: dropDownValues"
style="width:65px" />
</script>
curateExcelData: function (data) {
var sheet = data.workbook.sheets[0];
$.each(sheet.rows, function (index, row) {
if (row.type == "data") {
switch (row.cells[12].value) {
case "D":
row.cells[12].value = "Days";
break;
case "W":
row.cells[12].value = "Weeks";
default:
break;
}
}
});
},