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>
Kendo UI now supports export to both Excel and PDF. http://demos.telerik.com/kendo-ui/grid/excel-export
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.
在github上我有一个项目,允许您将网格下载到CSV: Kendo Grid CSV Export
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.