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

Custom Popup editor AngularJs problem with Add mode and foreign columns

2 Answers 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 14 Mar 2016, 03:47 AM

Hi,

   I'm using kendo ui grid with some foreign columns.  I mean some dropdownlist to select Key/Value pair data.  It works fine in update mode, but not in add mode.

I started with this example

Here is a litle snippet.  AssignmentType is a column filled by an object with properties Id and Description (Edit mode is a dropdownlist).  You can see attach files to understand what I mean.

If I remove the column from grid, all works fine, but if the column is shown in the grid, the value for column AssignmentType is set to value "1" and not the object selected in the dropdownlist.

 

Thank you for your help

$scope.mainGridOptions = {
            dataSource: {
                transport: {
                    read: {
                        url: "/Request/GetRequests",
                        dataType: "json"
                    },
                    update: {
                        url: "/Request/UpdateRequest",
                        dataType: "json"
                    },
                    destroy: {
                        url: "/Request/DeleteRequest",
                        dataType: "json"
                    },
                    create: {
                        url: "/Request/CreateRequest",
                        dataType: "json"
                    },
                    parameterMap: function (options, operation) {
                        if (operation !== "read" && options.models) {
                            return { models: kendo.stringify(options.models) };
                        }
                    }
                },
                batch: true,
                pageSize: 20,
                schema: {
                    model: {
                        id: "RequestId",
                        fields: {
                            RequestId: { type: "number" },
                            AssignmentType: { },
                            RequestType: { },
                            CERType: { }
                        }
                    }
                }
            },
          pageable: true,
          height: 550,
          toolbar: ["create"],
          columns: [
                            { command: ["edit", "destroy"], title: " ", width: "250px" },
                            {
                                field: "RequestId",
                                filterable: false
                            },
                            {
                                field: "AssignmentType",
                                title: "AssignmentType",
                                template: "#=AssignmentType == null ? '' : AssignmentType.Description#"

                            },
                            {
                                field: "RequestType",
                                title: "RequestType",
                                template: "#=RequestType == null ? '' : RequestType.Description#"
                            },
                            {
                                field: "CERType",
                                title: "CERType",
                                template: "#=CERType == null ? '' : CERType.Description#"
                            }            

2 Answers, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 17 Mar 2016, 07:57 AM

Hello Steve,

Although, I'm not entirely sure what may be the cause for the issue you have described looking at the provided information, I suspect that it may be due to  AssignmentType missing a default value. Please set a defaultValue option for this field and see if it makes any difference in the observed behavior.

                       fields: {
                            RequestId: { type: "number" },
                            AssignmentType: {  defaultValue: {} },
                            /*..*/
                        }

 

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Steve
Top achievements
Rank 1
answered on 17 Mar 2016, 10:41 AM
Thank you Rosen, it works.
Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Steve
Top achievements
Rank 1
Share this question
or