Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
141039 | Nov 20,2018 10:00 AM UTC | Nov 22,2018 09:04 AM UTC | ASP.NET Core - EJ 2 | 3 |
![]() |
Tags: DataGrid |
Hi,
I have noticed that when an update is required, the request sent to the web api endpoint is slightly non-standard from a REST API perspective (I think!) - instead of making a PUT to (for example) api/orders/5 (where 5 is the id of the order to update), it makes a PUT to api/orders and places the id in the json body.
Is it possible to configure the grid to place the id in url (as above)?
Thanks in advance :)
[Index.cshtml]
<div>
<ejs-grid id="Grid" toolbar="@(new List<string>() { "Add", "Update", "Cancel" })" allowGrouping="true" allowFiltering="true" load="load">
<e-data-manager url="/api/Orders/" adaptor="WebApiAdaptor" crossdomain="true"></e-data-manager>
...
</ejs-grid>
</div>
<script>
window.customAdaptor = new ej.data.WebApiAdaptor();
customAdaptor = ej.base.extend(customAdaptor, {
update(dm, keyField, value, tableName) {
return {
type: 'PUT',
url: dm.dataSource.url + value[keyField], //This will generate the “PUT” action request as “api/Orders/5”
data: JSON.stringify(value)
};
}
});
</script>
<script>
function load(args) {
this.dataSource.adaptor = customAdaptor;
}
</script>
|
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.