Hello,
I have found the code to take the export to csv at one of your web documents. Below is the link : http://demos.telerik.com/aspnet-mvc/grid/customcommand.
I have implement same thing in my code to take export, and it is working, But when I filter the grid with option like column name "Name" then in grid the resultant view show the filtered data, but when I export them , it still expoting the previous view data which are before filltering:
Here is the code in my exporttocsv() action method:
public ActionResult exporttocsv(int page, string orderBy, string filter) { IEnumerable details = getList().AsQueryable().ToGridModel(page, 20, orderBy, string.Empty, filter).Data;
// remaining code is same as given on your link onlu column name are changes)
}
After filtring when exporttocsv() is called by clickng on "ExportToCsv" button. In that method parameter all the all page, string orderBy, string filter are 1,~,~ respectively. As on view we are passing thats . See below
<%= Html.Telerik().Grid(Model) .Name("Grid") .ToolBar(commands => commands .Custom() .HtmlAttributes(new { id = "export" }) .Text("Export to CSV") .Action("ExportCsv", "Grid", new { page = 1, orderBy = "~", filter = "~" }))
%>.
So how can I pass at runtime the filter argument, page, order by, so it will export the filtered data.
Thanks Aayushi Soni