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

How do I handle an AJAX request/response from a custom toolbar button?

2 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Harper
Top achievements
Rank 1
Harper asked on 25 Jun 2018, 05:21 PM
I have a grid with a custom toolbar button to do a "global" update to the grid items. The Action is a normal MVC controller that returns a JsonResult. The action works correctly, but I'm not sure how to correctly handle the response - IE is asking if I want to download or open the JSON response. What I need to do is check the response for success, and refresh the grid or display an error message. How can I wire this up? Apologies if there's an answer already - I've searched, but can't seem to find anything.

2 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 27 Jun 2018, 11:24 AM
Hello,

As far as I understand the requirement here is to use the custom button in the toolbar in order to make changes to one or more data items and sync its changes with the server. If so you can take advantage of the Kendo UI Grid API and Kendo UI DataSource API. 

A sample workflow for such scenario would be: 
  - access the dataSource property of the Kendo UI Grid to have a reference to the Kendo UI DataSource instance. 
  - the items in the DataSource can be accessed using the data method of the Kendo UI DataSource. 
  - once you have access to specific data item from the DataSource you can use set method to change the value for specific property.
  - when you are done with modifying items the sync method of the DataSource will make a call to the transport.update.url with updated items. 

If your scenario is different please provide more information in order to help you with your case. 

Regards,
Boyan Dimitrov
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
Harper
Top achievements
Rank 1
answered on 27 Jun 2018, 05:38 PM

Boyan,

    Thanks for the direction - I was thinking in terms of the Action() method, but the javascript route seems preferable.

 

Harper

Tags
Grid
Asked by
Harper
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Harper
Top achievements
Rank 1
Share this question
or