Custom Popup editor AngularJs problem with Add mode and foreign columns

3 posts, 1 answers
  1. Steve
    Steve avatar
    22 posts
    Member since:
    Feb 2016

    Posted 13 Mar 2016 Link to this post

    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. Answer
    Rosen
    Admin
    Rosen avatar
    3253 posts

    Posted 17 Mar 2016 Link to this post

    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!
     
  3. Steve
    Steve avatar
    22 posts
    Member since:
    Feb 2016

    Posted 17 Mar 2016 in reply to Rosen Link to this post

    Thank you Rosen, it works.
Back to Top