Ticket Q474597
Visible to All Users

Mvc GridView CustomBindings and ExportTo

created 12 years ago

To fill the MVC GridView I use Custom Bindings (manually generate and perform sql-query). I need to implement "Export to xls" function. I looked at the example http://mvc.devexpress.com/GridView/Export. Xls document generated in the method called ExportTo:

C#
public ActionResult ExportTo() { foreach(string typeName in GridViewDemosHelper.ExportTypes.Keys) { if(Request.Params[typeName] != null) { return GridViewDemosHelper.ExportTypes[typeName].Method(GridViewDemosHelper.ExportGridViewSettings, NorthwindDataProvider.GetInvoices()); } } return RedirectToAction("Export"); }

Instead of calling NorthwindDataProvider.GetInvoices() (which returns IQueryable) I need to generate and execute the sql-query.To do this I need to get the current state of sorting and filtering. How can I get this state in ExportTo method?

Answers approved by DevExpress Support

created 12 years ago (modified 12 years ago)

Hello Pavel,
GridView provides the capability to display partial data. However, in case of exporting, the entire data source is required. It is impossible to export only a part of data.
GridView should automatically apply its client state (grouping, sorting, etc.) to the provided data set.

    Comments (3)

      Ok, if I manually will implement export. Is there a way to just get the current state of sorting and filtering?

        Maybe I can call some js-function that submit to the server the current client state of gridview?

        DevExpress Support Team 12 years ago

          Hello Pavel,
          Please use recommendations from the following example to accomplish this task:
          GridView - How to export filtered data with Reports when using the BindToLINQ method with large data

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.