We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

ExportExcelAction GridPropertiesModel Equivalent

I need to know how to accomplish the mapping of additional parameters to the expel export in the GridProperties model.

This is what works in the GridBuilder
.Mappers(map =>
            {
                map.ExportExcelAction("ExportOrderDetails", new { account = Model.Order.CustomerNumber, orderNumber = Model.Order.OrderNumber });
            })
...

            .ToolBar(tools =>
                {
                    tools.Add(GridToolBarItems.ExcelExport);
                })

What is the equivalent of the above using the gridpropertiesmodel?

ToolbarSettings toolbar = new ToolbarSettings();
            toolbar.Enable = true;
            toolbar.Items.Add(new ToolbarOptions() { ItemType = GridToolBarItems.ExcelExport, Caption = "ExportOrderDetails", Mapper =  ?????});
            gridModel.ToolBar = toolbar;

1 Reply

AS Alan Sangeeth S Syncfusion Team March 27, 2014 06:23 AM UTC

Hi Thomas,

Thanks for using Syncfusion Products.

We are glad to let you know that your requirement can be achieved by using clientside event “OnToolbarClickEvent”. In that event handler we can be bind values to ExcelToExport action. Please refer the following code snippets.

Code Snippet:

[CONTROLLER]

public ActionResult GridFeatures()

{


ClientSideEvents =
new ClientSideEvents() { OnToolbarClickEvent = "ToolbarClick" },



}

public ActionResult ExportToExcel(string CustomerID)

{

var data = new GridSample1.Models.StudentDataContext().Student.Take(100).ToList();

 

return data.GridExportToExcel<Student>("GridExcel.xlsx", ExcelVersion.Excel2007);
}

[JAVASCRIPT]

function ToolbarClick(sender, args) {

$('#GenericListGrid_exportExcel').append($('#CustomerID'));

}    

For your convenience we have created a sample and the same can be downloaded from below link.

Sample:

http://www.syncfusion.com/downloads/support/directtrac/121679/GridSample1-1459410709.zip


Please let us know if you have any queries.

Regards,
Alan Sangeeth S


Loader.
Live Chat Icon For mobile
Up arrow icon