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

[Solved] Create operation being called even when i click delete/update

3 Answers 637 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sneha
Top achievements
Rank 1
Sneha asked on 24 Jul 2012, 10:59 AM
On click of delete/update it is calling create method.
Not able to figure out the problem. need help on this issue.

(function ($) {

    // Update API url
    var UPDATEUSER_API_URL = 'api/UserManagement/PostUpdateUser';
    // Delete API url
    var DELETEUSER_API_URL = 'api/UserManagement/DeleteUser';
    // Search API url
    var GETUSER_API_URL = 'api/UserManagement/GetUser';
    // Search By Id API url
    var GETUSERBYID_API_URL = 'api/UserManagement/GetUserById';


    $(function () {
        debugger;
            dataSource = new kendo.data.DataSource({
                transport: {
                    read: {
                        url: GETUSER_API_URL,
                        dataType: "json"
                    },
                    update: {
                        url: UPDATEUSER_API_URL,
                        contentType: 'application/json;charset=utf-8',
                        dataType: "json",
                        type: "PUT"
                    },
                    destroy: {
                        url: DELETEUSER_API_URL,
                        contentType: 'application/json;charset=utf-8',
                        type: "DELETE",
                        dataType: "json",
                    },
                    create: {
                        url: UPDATEUSER_API_URL,
                        dataType: "json",
                        type: "POST",


                    },
                    parameterMap: function (options, operation) {
                        if (operation !== "read" && options.models) {
                            return { models: kendo.stringify(options.models) };
                        }
                    }
                },
                batch: true,
                pageSize: 10,
                schema: {
                    model: {
                        id: "UserProfileID",
                        fields: {
                            UserProfileId: { validation: { required: false } },
                            Password: {type: "string", validation: { required: true } },
                            Username: { editable: true, validation: { required: true } },
                            FirstName: {type: "string", validation: { required: true } },
                            LastName: {type: "string", validation: { required: true } },
                            EmailId: {type: "string", nullable: false, validation: { required: true } },
                            IsSuperUser: { type: "boolean", validation: { required: false } },
                            RoleName: {nullable: false, validation: { required: true } },
                        }
                    }
                }
            }); 

3 Answers, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 01 Aug 2012, 10:11 AM
Hi!

I had the same issue when I found this post http://www.kendoui.com/blogs/teamblog/posts/12-07-26/hello_kendo_ui_part_2_ndash_grid_crud.aspx that helped me out.

I noticed that the url property of the Crud objects is set to a function not to a string as you do. This was my mistake as well.

After specifying a function instead of a string the Kendo grid should fire update for updates and delete for deletes (this was the case for me).

Regards,
Peter
0
Ryan
Top achievements
Rank 1
answered on 09 Feb 2015, 08:26 PM
I'm having this same problem. Unfortunately, I can't switch to using the function notation for the url, as I need to use the function to define the destroy call and use a custom $.ajax call. I'm seeing create called every time. What's the correct fix?

Also, I see that all the rows in my grid are submitted each time I call either create or delete. How can I get this to call for only the record on which I'm working?
0
Ryan
Top achievements
Rank 1
answered on 09 Feb 2015, 08:44 PM
Of course, as soon as I reverted a few small changes, everything worked fine.
Tags
Grid
Asked by
Sneha
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
Ryan
Top achievements
Rank 1
Share this question
or