Hi,
I have project where web api uses attribute routing and somehow rest binding doesn't work on my iggrid.
On other project without attribute routing it works and update method is called after editing ended.
What's the problem here? I'm getting 404 PUT localhost:53300/.../8281452
//controller // PUT api/values/5
[Route(Save)]
[HttpPut] public void Save (int id, [FromBody]Item value) { }
//js
$(function () { var dataURL = "">localhost:53300/.../values"; $("#grid1").igGrid({ dataSource: dataURL, primaryKey: "TIDnumber", restSettings: { update: { url: dataURL }, remove: { url: dataURL, batch: true }, create: { url: "dataURL", batch: true } }, autoGenerateColumns: false, height: "350px", width: "800px", columns: [ { headerText: "TIDnumber", key: "TIDnumber", dataType: "number" }, { headerText: "Description", key: "Description", dataType: "string" }, { headerText: "Quantity", key: "Quantity", dataType: "string" } ], features: [ { name: "Updating", editMode: 'row', editCellStarted: onEditCellStarted, editRowEnded: onEditCellEnded, columnSettings: [{ columnKey: 'TIDnumber', readOnly: true }, { columnKey: "Description", editorType: 'string', validation: true, editorOptions: { required: true } } ] } ] });
});
thank you
Hello Robson,
Thank you for posting in our forum.
Could you let me know what is the route you have defined for the Save method? -> [Route(Save)] . Is this a custom route with a different format than the convention-based routing?
By default the grid on update will make a PUT request to the specified update url in the following format: updateUrl/{id}, which should match the conventional global web api route - "api/{controller}/{id}".
In this case if the specified url is : “localhost/values”, then the request will be send to “localhost/values/<RowID>”. In case you have specified a different route via attribute routing then it is possible for the grid request to no longer match it.
If you wish to change the url template that the grid uses to build its request url you can set the restSettings.update.template option - https://www.igniteui.com/help/api/2019.1/ui.iggrid#options:restSettings.update.template, so that it matches the specified custom route you have defined for your Save method. You can read more on how to set custom urls in the docs: https://www.igniteui.com/help/iggrid-rest-updating#custom-url
Let me know if that solves your issue.
Regards,
Maya Kirova