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

Grid with Batch editing and custom ParameterMap

1 Answer 338 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bach
Top achievements
Rank 1
Bach asked on 18 Jul 2016, 10:21 AM

Hi,

I encounter one issue while try to implement the grid to my project:

My current source:

01.skillsGrid_DS = new kendo.data.DataSource({
02.                transport: {
03.                    read:  {
04.                        url: skillsGrid_svc,
05.                        dataType: "json",
06.                        beforeSend: function (xhr) {
07.                            return Core.RESTFulSettings(xhr, site.sessionToken);
08.                        }
09.                    },
10.                    create: {
11.                        url: skillsGrid_svc,
12.                        dataType: "json",
13.                        type: "POST",
14.                        beforeSend: function (xhr) {
15.                            return Core.RESTFulSettings(xhr, site.sessionToken, "POST");
16.                        }
17.                    },
18.                    update: {
19.                        url: skillsGrid_svc,
20.                        dataType: "json",
21.                        type: "POST",
22.                        beforeSend: function (xhr) {
23.                            return Core.RESTFulSettings(xhr, site.sessionToken, "POST");
24.                        }
25.                    },
26.                    parameterMap: function(options, operation) {
27.                        if (operation !== "read" && options.models) {
28.                            return kendo.stringify(postData);
29.                        }
30.                    }
31.                },
32.                serverPaging: true,
33.                batch: true,
34.                pageSize: 20,
35.                schema: {
36.                    model: {
37.                        fields: {
38.                            SkillCode: { type: "number", validation: { required: true} },
39.                            Core: { type: "boolean" },
40.                            YearOfExperienceCodeId: { type: "number", validation: { required: true } }
41.                        }
42.                    }
43.                }
44.            });
45. 
46.$('#SkillsGrid').kendoGrid({
47.                    dataSource: skillsGrid_DS,
48.                    editable: "inline",
49.                    pageable: true,
50.                    toolbar: ["create", "save", "cancel"],
51.                    columns: [
52.                        {field: "ClassificationCode", editor: vm.editor_Classifications,  validation: { required: true } },
53.                        {field: "ElementCode", editor: vm.editor_Elements,  validation: { required: true } },
54.                        {field: "SkillRequired", title: "Skill Required", editor: vm.editor_SkillResource,  validation: { required: true } },
55.                        {field: "Core", width:"75px",  validation: { required: true }},
56.                        {field: "YearOfExperienceCodeId", width:"150px",  validation: { required: true }, editor: vm.editor_YrsExperience, title: "Yrs of Experience"},
57.                        {title: " ", width:"75px", command: "destroy"}
58.                    ]
59.                });

And the issues are:

 - As soon as I click on "CREATE" button, the row I entered gone and replaced by a blank row

 - I want to submit the batch in format below but the requested data is included all columns content

1.[{"SkillCode": "1", "Core": "true", "YearOfExperienceCodeId":"4"},
2. {"SkillCode": "132", "Core": "false", "YearOfExperienceCodeId":"1"}]

I'm looking a lot from the forum and cant find my answers. Could you please help me for more information about it.

Thank you and Best regards,

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 20 Jul 2016, 08:03 AM
Hello,

I am not sure what could be causing the problem when creating a new record. The described behavior usually occurs when the dataSource autoSync option is enabled but this does not seem to be the case from the code that you provided. Could you provide a runnable sample that demonstrates the issue?

As for sending only specific fields to the server - you should use the parameterMap function to create an array only with the required fields and return it as result.

Also, I noticed a the following issues in the provided code:
  • batch updates are supported by the grid only when the editable option is set to incell editing and the grid is configured for inline editing.
  • The editing requires the model id field to be defined in order to work correctly.
  • There seems to be validation option set to the columns which is not supported. You should set the option to the model fields. If custom editor is used, you should also add the corresponding validation attribute for the build-in rules to the input.

Regards,
Daniel
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
Grid
Asked by
Bach
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or