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

Kendo Grid MVVM Export to Excel Proxy for IE9

2 Answers 169 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 14 Oct 2015, 06:50 PM

Hi, so I am trying to set the proxy url for the export to excel functionality. I've already developed a jsp to serve the data but then they switched my project to MVVM, and now I am not sure how to set the proxy url.

 I am calling the saveAsExcel() function from a custom function (we have a custom grid toolbar so I had to make my own export button).

 Some code included below, where do I set the proxy URL?

In the grid view:

data-toolbar= [{'template':kendo.template($("#break-details-toolbar-template").html())}]

In the view toolbar template:

<div class="toolbar">
                    <button id="excelButton" class="excelButton k-button"
                        data-role="button"
                        data-bind="visible: isVisible, enabled: isEnabled,{ click: exportExcel }">
                        <i class="fa fa-file-excel-o"></i> Export To Excel
                    </button>
                    <button id="pdfButton" class="pdfButton k-button"
                        data-role="button"
                        data-bind="visible: isVisible, enabled: isEnabled,{ click: exportPdf }">
                        <i class="fa fa-file-pdf-o"></i> Export To PDF
                    </button>
                </div>​

 

 

click handler calls this function:

 function exportToExcel(gridID, columnsToExclude){
          
          
            $("div[data-role='grid']").each(function(){
                if( $(this)[0].id == gridID ){
                    var grid = $(this).closest("div[data-role='grid']").data("kendoGrid");
                    //loop through columns to hide columns to ignore
                    for(var i = 0; i < grid.columns.length; i++){
                        for(var j = 0; j < columnsToExclude.length; j++){
                            console.log(columnsToExclude[j]);
                            if(columnsToExclude[j] === grid.columns[i].title){
                                console.log("Match found - hiding column");
                                grid.columns[i].hidden = true;
                            }
                        }
                    }
                    grid.saveAsExcel();
                }
            });
            
};​

 

2 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 19 Oct 2015, 07:03 AM
Hi,

Please accept my apologies for the delayed response.

The saveAsExcel method will use the excel configuration set on the widget, e.g.
  data-excel='{ proxyUrl: "http://xxx.yyy/zzz", fileName: "Export.xlsx"}'

I hope this helps.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Nick
Top achievements
Rank 1
answered on 19 Oct 2015, 04:05 PM

Hello, thank you for responding. I was able to figure this one out a few days ago, my resolution was almost identical to what you provided, however I am using double quotes on the outside and single quotes on the inside.

data-excel= "{ 'fileName': '​Export.xlsx', 'filterable': true,
                    'proxyURL': 'path/js/export.jsp'}"

 

Thank you,

Nick

Tags
Grid
Asked by
Nick
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Nick
Top achievements
Rank 1
Share this question
or