Kendo网格Excel导出带有DropDown模板的列

我想导出kendo网格数据到excel。 我正在使用kendo dropdownlist作为一些列的模板。

当我出口它的出口,但不显示这些列的文本值,而是显示该字段的值。

这可能不是“最好”的解决scheme,但它对我有用。 基本上,我创build了一个函数,通过下拉菜单循环处理行,使用switch语句根据值设置文本(不幸的是,只有值而不是对象)。

这是我的网格的标记:

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

这里是更新导出的值(在我的情况下,我有一个下拉是“天”和“周”,这是第12列)的函数:

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