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

Unable to Update Grid via ODATA-V4

2 Answers 229 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stephan
Top achievements
Rank 1
Stephan asked on 12 Feb 2015, 05:37 PM
Hello,

Kendo UI version:
http://cdn.kendostatic.com/2014.3.1119/js/kendo.all.min.js    with
http://cdn.kendostatic.com/2014.3.1119/js/angular.min.js

OS:
Win7 64bit /  Win8.1 64bit

exact browser version:
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0

jQuery version:
http://cdn.kendostatic.com/2014.3.1119/js/jquery.min.js


----------------------------------------------------

I have an interface to an ODATA-V4 service which supports CRUD.
Read is working fine, only updating of data causing troubles.

In code I set a dynamic update URL by a function.
Then I tried to send (via pressing SAVE button in Kendo grid toolbar) a update request to ODATA service but nothing happens.
I did some investigations (F12 tools) to the corresponding request packet and I found out that the packet is using the method "OPTIONS" instead of "PUT".
The JSON for the model is missing in attachment (parameters) of the request.
When I remove the URL statement from update statement then "PUT" is send  but (of course) to the wrong address.
In this case the JSON for the model in attachment (parameters) of the request is available.

Do I something wrong and if not, is there any chance to fix it or to get a workaround?

Thanks, Stephan



Here is the complete datasource code:
$scope.mainGrid = {
 
                dataSource: {
                    type: "odata-v4",
                    transport: {
                        
                        read: {
                            url: "http://xxx.xxx.xxx.xxx/abc/odata/def/Areas"
                        },
                        update: {
                            url:  function (data) {
                                    return "http://xxx.xxx.xxx.xxx/abc/odata/def/Areas(" + data.models[0]._Key + ")";
                                },   
                            dataType: "json",   
                            type: 'PUT'
                        },
                        create: {
                            url: "http://xxx.xxx.xxx.xxx/abc/odata/def/Areas"
                        },
                        parameterMap: function(options, operation) {
                          if (operation !== "read") {
                            return kendo.stringify(options);
                          }
                        },
                    },
                    schema: {
                        model: {
                            id: "_Key",
                            fields: {
                                AreaGlobalName: { type: "AreaGlobalName" },
                                _Key: { type: "_Key" }
                            }
                        },
                    },
                    batch:true,
                    pageSize: 5,
                    serverPaging: false,
                    serverSorting: false
                
                },
                ......

2 Answers, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 13 Feb 2015, 05:15 PM
Hello Stephan,

Feel free to continue our conversation in this or the other thread that you opened on the same subject. Meanwhile you can check the following topic regarding CORS requests and PUT, DELETE operations:

http://stackoverflow.com/questions/7587812/unable-to-make-put-post-delete-http-call-using-cors-in-jquery-1-6-4

Kind Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Stephan
Top achievements
Rank 1
answered on 20 Feb 2015, 09:36 AM
Hello Petur,

Thanks for answer.
It was very helpful, now I understand how the requests are working. The ODATA service was blocking the OPTIONS request due to CORS. We changed this at the ODATA service and now it is working fine.

Regards, Stephan
Tags
Grid
Asked by
Stephan
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Stephan
Top achievements
Rank 1
Share this question
or