[英]By using kendo how to export the grid data to any one of the following files (csv,excel ,Pdf)
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. 我使用远程数据将数据填充到Kendogrid中。因此可以使用kendoUI将网格中的数据导出到任何文件,如csv,excel和pdf。
<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. Kendo UI现在支持导出到Excel和PDF。 http://demos.telerik.com/kendo-ui/grid/excel-export 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. 如果您使用的是ASP.NET MVC,那么有一个代码库示例可以演示这一点,但如果您不使用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. 这里是一个链接 ,可能是帮助它显示如何导出一个JSON响应CVS。
So what you want to do is get the datasource of your grid and call .toJson Something like this 所以你想要做的是获取网格的数据源并调用.toJson这样的东西
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() 视图将是dataSource.view()
Hope this helps. 希望这可以帮助。
在github上我有一个项目,允许您将网格下载到CSV: Kendo Grid CSV Export
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.