when i click on delete first time i get error on delete when i click delete again i get 2 delete requests. the one i made first time and the one i made the second time. if i click the third time so i get 3 errors and so on
link to stackoverflow question(with code):
https://stackoverflow.com/questions/48561985/kendo-ui-datasource-make-several-delete-calls-each-time
12 Answers, 1 is accepted
Thank you for the details.
Based on the screenshots there is an error on the server. This is creating a scenario, where the Grid does not receive a success on the delete operation and it tries to send in again until it is successful.
Please debug the server the determine why the request is not successful.
If a fully runnable example is provided I will be happy to investigate it locally and advise on how it can be resolved.
Regards,
Stefan
Progress Telerik
hi stefan
the server return error becouse we did operation that we should get an error. (so its not bug on the server side).
i want get error from the server.
but what i need to do so in the next call only the relevant api call will be triggered?
i mean that we have some entity that we want to delete and based on the logic in the server we cant delete it and the server return error.
so how can we make the datasource to send only the relevant request and not all the requests?
for me the error from the server is what i want to get, but i need the datasource will see it as "success" and not error so it will not send this request again.
if its not clear i will try to make code sample
thanks,
alex
Yes, it will be helpful to provide some example or more details.
In general, the Grid is designed to delete, update or create records only when the server return success. Returning an error and still deleting the records will collide with the standard practices when handling CRUD operations with a server and a database.
Please advise a scenario, when the server should return an error but the record should be removed anyway?
I will be expecting more details and gladly assist.
Regards,
Stefan
Progress Telerik
hi stefan
when the server return error im not deleting the row. we delete the row only on success.
but the problem is that next time i will try to delete any row and get error from the server so it will send all the requests that returned error.
and we want only 1 request will be sent to the server .
in the screenshot of the error you can see that.
for example im trying to delete row with id=1.
i got error and not deleted the row.
now im trying to delete row with id=2.
what happens now is when i try delete id=2 the datasource send delete request of id=1 + id=2.
what i want is to send only the request of the specific row im trying to delete.
it will take me some time to provide code example so if its not clear i will work on it.
Thanks
Alex
Thank you for the clarification.
This will automatically happen if in the first unsuccessful request a model error is returned.
I made a video showing that if the server returns a model error the Grid will send only the second records to the server:
https://www.screencast.com/t/q9qcfJsP8
I made a simple check on the server to add a model error on the items with ID 1 and 2:
if
(products.Any())
{
foreach
(var product
in
products)
{
productService.Destroy(product);
if
(product.ProductID == 1 || product.ProductID == 2)
{
ModelState.AddModelError(
"cannot delete"
,
"test"
);
}
}
}
I will be expecting the example as I assume that the result from the first request is not expected.
Please also check the CRUD operation article with can prove helpful:
https://docs.telerik.com/kendo-ui/framework/datasource/crud
Regards,
Stefan
Progress Telerik
hi stefan
sorry for the late response ,
i have made video that shows the error.
i watched your video and it looks the same as yours.
this is the link, hope you can help us understand the problem.
https://www.screencast.com/t/3iYuTQ45XNt
thanks
Alex
Thank you for the video.
The two things that got my attention are the status code and the message.
In our case, the code is 500 and the state is an error, and in the real application, it is 400 with status failure.
Please check if changing the status type will change the behavior.
In the meantime, I will check as well as the Grid is expecting specific codes in order to remove the previous items from the request.
Regards,
Stefan
Progress Telerik
thanks stefan
i will try to change and will update you
hi stefan
iv'e made the change in the server side and it not solved the issue.
Thank you for the tests.
I made more tests as well and indeed the behavior that you are observing is the expected one. This is the default behavior, but it can be changed.
I can suggest calling cancelChanges on the error event of the data source. This will remove all changes and it will not send additional requests to the dataSource if they have failed before:
https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/events/error
https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/methods/cancelchanges
This should be able to prevent the undesired default behavior.
Regards,
Stefan
Progress Telerik
it works now :)
thank you very much for your support.