I was using Telerik Grid in MVC3 project. In this I have to use the functionality of exporting. In order to export data, I need all the currently available items should be exported as excel format.
I done with exporting. But I need to export all the data currently are available in the grid. It means when filtering Not only the current page's data, It should export all the filtered data's.
I have done something like this: But its not exporting only the filtered data's but all the data's in the grid.
View Code
@(Html.Telerik().Grid(Model)
.Name("Grid")
.ToolBar(commands => commands
.Custom()
.HtmlAttributes(new { id = "export" })
.Text("Export to Excel")
.Action("ExportExcel", "Grid",
new { page = 1, orderBy = "~", filter = "~" }))
.DataKeys(keys =>
{
keys.Add(Id => Id.Itemid);
})
Action Method in my Controller
public ActionResult ExportExcel(int page, string orderBy, string filter)
{
IEnumerable orders = GetItems()
.AsQueryable()
.ToGridModel(page, int.MaxValue, orderBy,
string.Empty, filter).Data;
Is there any way that I can do with this. Please help for this.
Thanks,
The following example shows how to export only the relevant data: http://demos.telerik.com/aspnet-mvc/grid/customcommand
There is also a code library project which shows how to export the grid data to Excel: http://www.telerik.com/support/kb/aspnet-mvc/grid/export-to-excel.aspx