1

I am filling the data into Kendogrid using remote data.So is it possible to export data the data in the grid to any files like csv,excel and pdf using kendoUI.

   <script>
    $(document).ready(function() {
                            $("#grid").kendoGrid({
                                dataSource: {
                                    type: "odata",
                                    transport: {
                                        read: "http://demos.kendoui.com/service/Northwind.svc/Orders"
                                    },
                                    schema: {
                                        model: {
                                            fields: {
                                                OrderID: { type: "number" },
                                                Freight: { type: "number" },
                                                ShipName: { type: "string" },
                                                OrderDate: { type: "date" },
                                                ShipCity: { type: "string" }
                                            }
                                        }
                                    },
                                    pageSize: 10,
                                    serverPaging: true,
                                    serverFiltering: true,
                                    serverSorting: true
                                },
                                height: 250,
                                filterable: true,
                                sortable: true,
                                pageable: true,
                                columns: [{
                                        field:"OrderID",
                                        filterable: false
                                    },
                                    "Freight",
                                    {
                                        field: "OrderDate",
                                        title: "Order Date",
                                        width: 100,
                                        format: "{0:MM/dd/yyyy}"
                                    }, {
                                        field: "ShipName",
                                        title: "Ship Name",
                                        width: 200
                                    }, {
                                        field: "ShipCity",
                                        title: "Ship City"
                                    }
                                ]
                            });
                        });
                    </script>
5
  • 1
    you can read the full datasource using $("#grid").data("kendoGrid").dataSource.data()
    – Arun Killu
    Jan 23, 2013 at 5:13
  • this has nothing to do with kendo actually you are generating the data .and you can convert it to any format.
    – Arun Killu
    Jan 23, 2013 at 5:22
  • when ever user clicks the button I need to export the data.I tired like this but no use. $("#download").click(function () { var json = $.parseJSON($("#json").val()); var csv = JSON2CSV(json); window.open("data:text/csv;charset=utf-8," + escape(csv)) }); Jan 23, 2013 at 5:26
  • is it possible to change the file name .Presently I am getting download.xls I want to change this name Mar 13, 2013 at 10:31
  • I append the response.Addheader but no use .and It was showing as unexpected identifier error Mar 13, 2013 at 10:34

3 Answers 3

2

Kendo UI now supports export to both Excel and PDF. http://demos.telerik.com/kendo-ui/grid/excel-export

1
1

Unfortunately there isn't any built in functionality for exporting the grid.

There is a code library example that demonstrates this if you are using ASP.NET MVC but I don't know of one if you are not using MVC. According to some forum answers they do not have plans to build this in which I don't like and hope we as users can vote for this feature.

Here is a link that may be of help it shows how to export a json response to cvs.

So what you want to do is get the datasource of your grid and call .toJson Something like this

      var mydata= $("#grid").data("kendoGrid").dataSource.data().toJson();

Then pass that to the function in the link I provided

Also note: you may need to get the view of the datasource if you want to include the filtering and paging, at least I think. view would be dataSource.view()

Hope this helps.

3
  • yes what you said is correct,I are not using MVC,using kendo html web .The kendo provided MVC example also not able to open as it was vs 2013.anyway thanks for responding. Jan 23, 2013 at 6:29
  • Just as a side not jqwidgets grid has a function to export to excel you could take a look at their javascript export function and apply it to kendoUI jqwidgets.com/jquery-grid-export-to-excel
    – dan
    Jan 23, 2013 at 12:31
  • Ok I have already seen this and they have in built function $("#jqxgrid").jqxGrid('exportdata', 'xls', 'jqxGrid'); but in kendo I have not found such functionality. Jan 23, 2013 at 12:44
0

On github I have a project that allows you to download the Grid to a CSV: Kendo Grid CSV Export

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.