Skip to content

Commit b78af53

Browse files
documentation(384809):Updated.
1 parent bccae51 commit b78af53

File tree

6 files changed

+88
-0
lines changed

6 files changed

+88
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public IActionResult Index()
2+
{
3+
return View();
4+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@Html.EJS().Grid("CustomAdaptor").Columns(col =>
2+
{
3+
col.Field("CustomerID").HeaderText("Customer ID").Width("160").Add();
4+
col.Field("Freight").HeaderText("Freight").Width("150").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
5+
col.Field("ShipCity").HeaderText("Ship City").Width("150").Add();
6+
col.Field("ShipCountry").HeaderText("Ship Country").Width("150").Add();
7+
8+
}).Created("created").Render()
9+
10+
<script>
11+
function created(args) {
12+
class CustomAdaptor extends ej.data.WebApiAdaptor {
13+
beforeSend(args, xhr, settings) {
14+
xhr.withCredentials = true;
15+
super.beforeSend(args, xhr, settings);
16+
xhr.headers.set('Syncfusion', true);
17+
}
18+
}
19+
var grid = document.querySelector('#CustomAdaptor').ej2_instances[0];
20+
grid.dataSource = new ej.data.DataManager({
21+
url: "https://services.syncfusion.com/js/production/api/orders",
22+
adaptor: new CustomAdaptor()
23+
});
24+
}
25+
</script>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<ejs-grid id="CustomAdaptor" created="created">
2+
<e-grid-columns>
3+
<e-grid-column field="CustomerID" headerText="Customer Name" width="150"></e-grid-column>
4+
<e-grid-column field="Freight" headerText="Freight" format="C2" width="120"></e-grid-column>
5+
<e-grid-column field="ShipCity" headerText="Ship City"></e-grid-column>
6+
<e-grid-column field="ShipCountry" headerText="Ship Country" width="150"></e-grid-column>
7+
</e-grid-columns>
8+
</ejs-grid>
9+
10+
<script>
11+
function created(args) {
12+
class CustomAdaptor extends ej.data.WebApiAdaptor {
13+
beforeSend(args, xhr, settings) {
14+
xhr.withCredentials = true;
15+
super.beforeSend(args, xhr, settings);
16+
xhr.headers.set('Syncfusion', true);
17+
}
18+
}
19+
var grid = document.querySelector('#CustomAdaptor').ej2_instances[0];
20+
grid.dataSource = new ej.data.DataManager({
21+
url: "https://services.syncfusion.com/js/production/api/orders",
22+
adaptor: new CustomAdaptor()
23+
});
24+
}
25+
</script>

ej2-asp-core-mvc/grid/EJ2_ASP.MVC/data-binding/data-binding.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,23 @@ The following example demonstrates how to prevent local time zone conversion for
257257

258258
![Prevent to convert local time zone format](../images/databinding/local-time.gif)
259259

260+
## How to set custom headers using a custom adaptor in Syncfusion Grid
261+
262+
Custom headers allow you to send extra information along with your HTTP requests. This information can include authentication tokens, API keys, or any other data required by the server to process the request correctly. By adding custom headers, you can enhance the security and functionality of your application's data communication process.
263+
264+
This section explains how to integrate custom headers into Syncfusion Grid using the `beforeSend` method of the `WebApiAdaptor`.
265+
266+
{% tabs %}
267+
{% highlight razor tabtitle="CSHTML" %}
268+
{% include code-snippet/grid/data-binding/custom-headers/razor %}
269+
{% endhighlight %}
270+
{% highlight c# tabtitle="custom-headers.cs" %}
271+
{% include code-snippet/grid/data-binding/custom-headers/custom-headers.cs %}
272+
{% endhighlight %}
273+
{% endtabs %}
274+
275+
![Custom headers using custom adaptor](../images/custom-headers.png)
276+
260277
## Troubleshoot: Syncfusion ASP.NET MVC Grid render rows without data
261278

262279
In ASP.NET MVC, by default the JSON results are returned in camelCase format. So Grid field names are also changed in camelCase.

ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/data-binding/data-binding.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,23 @@ The following example demonstrates how to prevent local time zone conversion for
257257

258258
![Prevent to convert local time zone format](../images/databinding/local-time.gif)
259259

260+
## How to set custom headers using a custom adaptor in Syncfusion Grid
261+
262+
Custom headers allow you to send extra information along with your HTTP requests. This information can include authentication tokens, API keys, or any other data required by the server to process the request correctly. By adding custom headers, you can enhance the security and functionality of your application's data communication process.
263+
264+
This section explains how to integrate custom headers into Syncfusion Grid using the `beforeSend` method of the `WebApiAdaptor`.
265+
266+
{% tabs %}
267+
{% highlight cshtml tabtitle="CSHTML" %}
268+
{% include code-snippet/grid/data-binding/custom-headers/tagHelper %}
269+
{% endhighlight %}
270+
{% highlight c# tabtitle="custom-headers.cs" %}
271+
{% include code-snippet/grid/data-binding/custom-headers/custom-headers.cs %}
272+
{% endhighlight %}
273+
{% endtabs %}
274+
275+
![Custom headers using custom adaptor](../images/custom-headers.png)
276+
260277
## Troubleshoot: Syncfusion ASP.NET Core Grid render rows without data
261278

262279
In ASP.NET Core, by default the JSON results are returned in camelCase format. So Grid field names are also changed in camelCase.
71.3 KB
Loading

0 commit comments

Comments
 (0)