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

data going as null from editable grid to webapi layer on Update/Create

1 Answer 170 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:22 AM
Below is the code that i have written. On click of create/update data is not being send to webapi layer and on every click it is calling create operation. Help me to resolve the above 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 } },
                        }
                    }
                }
            });
        debugger;
        $("#grid").kendoGrid({
            dataSource: dataSource,
            pageable: true,
            height: 400,
            toolbar: ["create"],
            columns: [
                "Username",
                { field: "Password", title: "Password", width: "1px" },
                "FirstName",
                "LastName",
                { field: "EmailId", title: "Email Id", width: "170px" },
                { field: "IsSuperUser", title: "SuperUser", width: "90px" },
                { field: "RoleName", title: "Roles", width: "90px"  },
                { command: ["edit", "destroy"], title: " ", width: "210px" }],
            editable: "popup"
        });
    });

1 Answer, 1 is accepted

Sort by
0
Ednei
Top achievements
Rank 1
answered on 27 Jul 2012, 12:30 PM
You have some "," in many places incorrectly.

Just remove in below bold lines:


Posted on Jul 24, 2012

Below is the code that i have written. On click of create/update data is not being send to webapi layer and on every click it is calling create operation. Help me to resolve the above 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 } },
                        }
                    }
                }
            });
        debugger;
        $("#grid").kendoGrid({
            dataSource: dataSource,
            pageable: true,
            height: 400,
            toolbar: ["create"],
            columns: [
                "Username",
                { field: "Password", title: "Password", width: "1px" },
                "FirstName",
                "LastName",
                { field: "EmailId", title: "Email Id", width: "170px" },
                { field: "IsSuperUser", title: "SuperUser", width: "90px" },
                { field: "RoleName", title: "Roles", width: "90px"  },
                { command: ["edit", "destroy"], title: " ", width: "210px" }],
            editable: "popup"
        });
    });
Tags
Grid
Asked by
Sneha
Top achievements
Rank 1
Answers by
Ednei
Top achievements
Rank 1
Share this question
or