We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How To Change the request URL when performing Insert, Update and Delete in the data grid toolbar button?

Hi,

I have been tried to insert records from the data grid by using the Editing function with the WebApiAdaptor method. I noticed that the request URL pointing to the server-end is having a default format. 

For an example: 
1. When Insert, the URL will be like http://localhost:4000/api/users (POST)
2. When Update, the URL will be like http://localhost:4000/api/users (PUT)
3. When Delete, the URL will be like http://localhost:4000/api/users//undefined (DELETE)

Is that possible I can define my own API URL? I have tried to append the insertUrl: "http://localhost:4000/api/add-user"; updateUrl: http://localhost:4000/api/update-user; but it seems not working with it.

Besides, I also noticed that when performing inserting, we can define a default value on the column by using the params, but how can I bind the params to a drop down list for the particular column with multiple choice?

Hope you can assist me as soon as possible.

Attachment: Dashboard_1744ca2f.rar

1 Reply

PS Pavithra Subramaniyam Syncfusion Team November 12, 2019 12:01 PM UTC

Hi Chew, 
 
Thanks for contacting Syncfusion support. 
 
As per webApi standard, we have send Http POST, PUT, DELETE request to perform the CRUD actions in server side and we don’t have support to define CRUD URL in webApiAdaptor. However, you can achieve your requirement by customizing the default WebApiAdaptor. 
 
  class SerialNoAdaptor extends ej.data.WebApiAdaptor { 
            insert(dm, data, tableName) { 
                return { 
                    type: 'POST', 
                    url: dm.dataSource.url, 
                    data: JSON.stringify(data) 
                }; 
            } 
 
            remove(dm, keyField, value, tableName) { 
                return { 
                    type: 'DELETE', 
                    url: dm.dataSource.url + '/' + value, 
                    data: JSON.stringify(value) 
                }; 
            } 
            update(dm, keyField, value, tableName) { 
                return { 
                    type: 'PUT', 
                    url: "Home/update",  // you can define the update url here 
                    data: JSON.stringify(value) 
                }; 
            } 
        } 
 
 
Query:  how can I bind the params to a drop down list for the particular column with multiple choice? 
 
While using dropdownedit then we have an option to send params to corresponding column dropdown list. Please refer the below documentation for more information. 
 
 
If you want to customize the dropdown list then you can use edit template feature to achieve your requirement. If the provided suggestion does not meet your requirement then share more details about your query that will helpful for us to validate further at our end. 
 
Regards, 
Pavithra S. 


Loader.
Live Chat Icon For mobile
Up arrow icon