This is a migrated thread and some comments may be shown as answers.

Command, rowTemplate, and export CSV

1 Answer 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Wesley
Top achievements
Rank 1
Wesley asked on 22 Apr 2014, 01:55 AM
Hi,

I am working on a dataGrid, which needs to be editable, and able to export CSV file.


so the columns  this:

columns: [{command: ["edit"], title: " ", width: "100px"},
{field:"channelId", title: dict.channel,template:'#: channelList[(channelId-1)]#'},
{field:"campaignId", title:dict.campaign,editor: disabledEditor},
{field:"status", title:dict.status,template:'<span style="text-transform:lowercase">#: status#</span>'},
{field:"budget", title:dict.budget+' (USD)', type: "number",format: "{0:c2}"},

{field:"impressior", title:dict.impressior,type: "number"},
{field: "clcik", title:dict.click,type: "number"},
{field: "dailyBudget", title:dict.cost,type: "number",format: "{0:c}"},
{field: "conv", title:dict.conv,type: "number"},
{field: "avgPost", title:dict.avgPost,type: "number"},
{field: "ctr", title:dict.ctr,type: "number"},
{field: "cpc", title:dict.cpc,type: "number"},
{field: "cpa", title:dict.cpa,type: "number"}
],

I am using this method to export csv:
http://blog.falafel.com/Blogs/RachelHagerman/rachel-hagerman/2014/02/04/super-simple-spreadsheet-export-from-kendo-ui-grid

however, as I used 'template' in 'columns', the export CSV function crashed here:


if (value && template && exportFormat !== false) {
value = _.isFunction(template)
? template(data[row])
: kendo.template(template)(data[row]);
}

if I takes out 'template' from 'columns' and use 'rowTemplate' like this:
rowTemplate: '<tr data-uid="#= uid #"><td></td><td>#= channelList[(channelId-1)]#</td><td>#: campaignId#</td><td style="text-transform:lowercase">#: status#</td><td>#: budget#</td><td>#: impressior#</td><td>#: clcik#</td><td>#: dailyBudget#</td><td>#: conv#</td><td>#: avgPost#</td><td>#: ctr#</td><td>#: cpc#</td><td>#: cpa#</td></tr>',

 the CSV export script works, but the edit button do not appear

I tried to put '<a class="k-button k-button-icontext k-grid-edit" href="#"><span class="k-icon k-edit"></span>Edit</a>' in the row template like this example
but still not working



Another problem is, the value of one of the field is number, but what needs to be display are string, refer to an Array, like this:

 '#: channelList[(channelId-1)]#'

It only returns the number on the CSV


please help and  thanks






 

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 24 Apr 2014, 09:07 AM
Hi Wesley,

From the provided information it seems that the "underscore" library is missing from your project as it contains the function that you are referring ("isFunction"). You can find the "Underscore" library on following page:
After including the library the project start exporting the templates as expected on our side. 

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Wesley
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or