This is a migrated thread and some comments may be shown as answers.

kendo ui datasource make several delete calls each time

12 Answers 299 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 04 Feb 2018, 09:13 AM

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

Sort by
0
Stefan
Telerik team
answered on 06 Feb 2018, 09:30 AM
Hello, Alex,

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
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Alex
Top achievements
Rank 1
answered on 18 Feb 2018, 03:24 PM

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

 

0
Stefan
Telerik team
answered on 20 Feb 2018, 09:35 AM
Hello, 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
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Alex
Top achievements
Rank 1
answered on 20 Feb 2018, 03:58 PM

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

 

 

0
Stefan
Telerik team
answered on 22 Feb 2018, 08:57 AM
Hello, 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
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Alex
Top achievements
Rank 1
answered on 12 Aug 2018, 09:34 AM

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

0
Stefan
Telerik team
answered on 13 Aug 2018, 07:45 AM
Hello, 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
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Alex
Top achievements
Rank 1
answered on 13 Aug 2018, 08:12 AM

thanks stefan

i will try to change and will update you

0
Alex
Top achievements
Rank 1
answered on 13 Aug 2018, 12:40 PM

hi stefan

iv'e made the change in the server side and it not solved the issue.

 

0
Alex
Top achievements
Rank 1
answered on 13 Aug 2018, 12:43 PM
and this is the status changed to error
0
Stefan
Telerik team
answered on 14 Aug 2018, 07:09 AM
Hello, Alex,

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
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Alex
Top achievements
Rank 1
answered on 14 Aug 2018, 08:39 AM

it works now :)

thank you very much for your support.

Tags
Data Source
Asked by
Alex
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Alex
Top achievements
Rank 1
Share this question
or