Skip to content

Commit 7487645

Browse files
Merge pull request #3944 from syncfusion-content/additional-parameter-940669
Documentation(940696)-Need to add Additional parameters to server whe…
2 parents 309eb93 + 204e114 commit 7487645

File tree

8 files changed

+101
-3
lines changed

8 files changed

+101
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public IActionResult Index()
2+
{
3+
ViewBag.dataSource = OrderDetails.GetAllRecords();
4+
return View();
5+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<div style="margin-left:180px">
2+
<p style="color:red;" id="message"></p>
3+
</div>
4+
@Html.EJS().Grid("grid").DataSource((IEnumerable<object>)ViewBag.dataSource).AllowExcelExport().Toolbar(new List<string>
5+
() { "ExcelExport" }).ToolbarClick("toolbarClick").ExcelExportComplete("excelExportComplete").Columns(col =>
6+
{
7+
col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
8+
col.Field("CustomerID").HeaderText("Customer ID").Visible(false).Width("150").Add();
9+
col.Field("ShipCity").HeaderText("Ship City").Width("150").Add();
10+
col.Field("ShipName").HeaderText("Ship Name").Width("150").Add();
11+
}).Render()
12+
</div>
13+
<script>
14+
function toolbarClick(args) {
15+
var grid = document.getElementById("grid").ej2_instances[0];
16+
if (args.item.id === "grid_excelexport") {
17+
var queryClone = grid.query;
18+
grid.query = new ej.data.Query().addParams("recordcount", "15");
19+
document.getElementById("message").innerText = 'Key: ' + grid.query.params[0].key + ' and Value: ' + grid.query.params[0].value + ' on ' + args.item.text;
20+
grid.excelExport();
21+
}
22+
}
23+
24+
function excelExportComplete(args) {
25+
var grid = document.getElementById("grid").ej2_instances[0];
26+
grid.query = new ej.data.Query();
27+
}
28+
</script>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<div style="margin-left:180px">
2+
<p style="color:red;" id="message"></p>
3+
</div>
4+
<ejs-grid id="grid" dataSource="@ViewBag.dataSource" allowExcelExport="true" toolbarClick="toolbarClick" excelExportComplete="excelExportComplete" toolbar="@(new List<string>() { "ExcelExport" })">
5+
<e-grid-columns>
6+
<e-grid-column field="OrderID" headerText="Order ID" textAlign="Right" width="120"></e-grid-column>
7+
<e-grid-column field="CustomerID" headerText="Customer Name" visible="false" width="150"></e-grid-column>
8+
<e-grid-column field="ShipCity" headerText="Ship City" width="150"></e-grid-column>
9+
<e-grid-column field="ShipName" headerText="Ship Name" width="150"></e-grid-column>
10+
</e-grid-columns>
11+
</ejs-grid>
12+
<script>
13+
function toolbarClick(args) {
14+
var grid = document.getElementById("grid").ej2_instances[0];
15+
if (args.item.id === "grid_excelexport") {
16+
var queryClone = grid.query;
17+
grid.query = new ej.data.Query().addParams("recordcount", "15");
18+
document.getElementById("message").innerText = 'Key: ' + grid.query.params[0].key + ' and Value: ' + grid.query.params[0].value + ' on ' + args.item.text;
19+
grid.excelExport();
20+
}
21+
}
22+
23+
function excelExportComplete(args) {
24+
var grid = document.getElementById("grid").ej2_instances[0];
25+
grid.query = new ej.data.Query();
26+
}
27+
</script>

ej2-asp-core-mvc/grid/EJ2_ASP.MVC/excel-export/excel-exporting.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: post
3-
title: Excel Exporting in ##Platform_Name## Grid Component
3+
title: Excel Exporting in Syncfusion ##Platform_Name## Grid Component
44
description: Learn here all about Excel Exporting in Syncfusion ##Platform_Name## Grid component of Syncfusion Essential JS 2 and more.
55
platform: ej2-asp-core-mvc
66
control: Excel Exporting
@@ -253,6 +253,25 @@ In the following example, the [ToolbarClick](https://help.syncfusion.com/cr/aspn
253253

254254
![Add formula for the cell while exporting](../images/excel-exporting/excelexporting-formula.png)
255255

256+
## Passing additional parameters to the server when exporting
257+
258+
Passing additional parameters to the server when exporting data in the Syncfusion ASP.NET MVC Grid involves providing flexibility to include extra information or customize the export process based on specific requirements.
259+
260+
You can achieve this by utilizing the [Query](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_Query) property and the [ToolbarClick](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ToolbarClick) event. Within the `Query` property, you can invoke the `addParams` method to add parameters to the request.
261+
262+
The following example demonstrates how to pass additional parameters to the server when Excel exporting within the `ToolbarClick` event. Within the event, the additional parameters, specifically **Recordcount** as **15**, are passed using the `addParams` method and displayed as a message.
263+
264+
{% tabs %}
265+
{% highlight razor tabtitle="CSHTML" %}
266+
{% include code-snippet/grid/excel-export/additional-parameter/razor %}
267+
{% endhighlight %}
268+
{% highlight c# tabtitle="excel-export.cs" %}
269+
{% include code-snippet/grid/excel-export/additional-parameter/excel-export.cs %}
270+
{% endhighlight %}
271+
{% endtabs %}
272+
273+
![Passing additional parameters to the server when exporting](../images/excel-exporting/additional-parameter.png)
274+
256275
## Limitations
257276

258277
* A CSV is a plain text format that does not support features such as cell rotation, font and color customization, column and row spanning, or adding formulas. CSV files store raw data without any formatting or styling.
@@ -261,4 +280,4 @@ In the following example, the [ToolbarClick](https://help.syncfusion.com/cr/aspn
261280

262281
* [Copy & paste excel](https://www.syncfusion.com/blogs/post/essential-js-2-copying-and-pasting-excel-sheet-data-to-grid-asp-net-mvc.aspx)
263282

264-
* [Copy and pasting excel sheet data to Grid](https://www.syncfusion.com/blogs/post/copy-and-pasting-excel-sheet-data-to-syncfusion-grid-for-mvc.aspx)
283+
* [Copy and pasting excel sheet data to Grid](https://www.syncfusion.com/blogs/post/copy-and-pasting-excel-sheet-data-to-syncfusion-grid-for-mvc.aspx)

ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/excel-export/excel-exporting.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: post
3-
title: Excel Exporting in ##Platform_Name## Grid Component
3+
title: Excel Exporting in Syncfusion ##Platform_Name## Grid Component
44
description: Learn here all about Excel Exporting in Syncfusion ##Platform_Name## Grid component of Syncfusion Essential JS 2 and more.
55
platform: ej2-asp-core-mvc
66
control: Excel Exporting
@@ -253,6 +253,25 @@ In the following example, the [toolbarClick](https://help.syncfusion.com/cr/aspn
253253

254254
![Add formula for the cell while exporting](../images/excel-exporting/excelexporting-formula.png)
255255

256+
## Passing additional parameters to the server when exporting
257+
258+
Passing additional parameters to the server when exporting data in the Syncfusion ASP.NET Core Grid involves providing flexibility to include extra information or customize the export process based on specific requirements.
259+
260+
You can achieve this by utilizing the [query](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_Query) property and the [toolbarClick](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_ToolbarClick) event. Within the `query` property, you can invoke the `addParams` method to add parameters to the request.
261+
262+
The following example demonstrates how to pass additional parameters to the server when Excel exporting within the `toolbarClick` event. Within the event, the additional parameters, specifically **recordcount** as **15**, are passed using the `addParams` method and displayed as a message.
263+
264+
{% tabs %}
265+
{% highlight cshtml tabtitle="CSHTML" %}
266+
{% include code-snippet/grid/excel-export/additional-parameter/tagHelper %}
267+
{% endhighlight %}
268+
{% highlight c# tabtitle="excel-export.cs" %}
269+
{% include code-snippet/grid/excel-export/additional-parameter/excel-export.cs %}
270+
{% endhighlight %}
271+
{% endtabs %}
272+
273+
![Passing additional parameters to the server when exporting](../images/excel-exporting/additional-parameter.png)
274+
256275
## Limitations
257276

258277
* A CSV is a plain text format that does not support features such as cell rotation, font and color customization, column and row spanning, or adding formulas. CSV files store raw data without any formatting or styling.
Loading
Loading
Loading

0 commit comments

Comments
 (0)