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

Angular remote Datasource in Grid - update not working

2 Answers 147 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 02 Mar 2015, 10:02 AM
Note: This is a duplicate of http://www.telerik.com/forums/editable-grid-with-angular---update-not-working as I am not sure wheter this is a problem of the DataSource configuration or the grid configuration (or both).

I am using a kendo-ui grid together with angular and would like to
use it's edit functionality. However the update function is never called
when trying to edit its contents.

This is how I set the grid:


angular.module("KendoDemos", [ "kendo.directives" ])
        .controller("MyCtrl", function($scope){
            $scope.mainGridOptions = {
                dataSource: {
                    type: "odata",
                    transport: {
                        read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Employees",
                          update: function(options){
                          console.log("updated");
                        }
                    }
                },
                  editable: "inline",
                columns: [{
                    field: "FirstName",
                    title: "First Name",
                    width: "120px"
                    },{
                    field: "LastName",
                    title: "Last Name",
                    width: "120px"
                    },{
                    field: "Country",
                    width: "120px"
                    },{
                    field: "City",
                    width: "120px"
                    },{
                      command: ["edit", "destroy"],
                      title: " ",
                      width: "250px"
                    }]
            };
  
        })

Here is a fiddle to demonstrate it: http://jsfiddle.net/xLp6rLtj/

Even if I'm using a url instead of function in the
datasource.transport.update parameter, no request is made (and the
button can't be released).

What am I missing?

2 Answers, 1 is accepted

Sort by
0
Patrick
Top achievements
Rank 1
answered on 03 Mar 2015, 12:24 PM
I was able to resolve this. It seemed to be a problem with the dataSource configuration.

¨                    dataSource: {
                        batch: false,
                        transport: {
                            read: {
                                url: "http://www.......",
                                dataType: "json"
                            },
                            update: {
                                url: function(options) {
                                    return "http://www...." + options.id;
                                },
                                type: "PUT",
                                dataType: "json"
                            }
(...)


If done this way, it works.
 
English (Auto-Erkennung) » German
 
0
Vladimir Iliev
Telerik team
answered on 04 Mar 2015, 08:16 AM
Hi Patrick,


From the provided information it seems that the reason for current behavior is that the dataSource is missing the "dataSource.schema.model.id" and "dataSource.schema.model.field" options which is mendatory for enabling the editing:

Also you can send additional request parameters by setting the "transport.update.data" option to function which to return them: 

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Data Source
Asked by
Patrick
Top achievements
Rank 1
Answers by
Patrick
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or