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

Id column in the grid not updated during insert when batch=true

1 Answer 223 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 28 Jan 2013, 09:30 AM
Hi i am using kendo grid in my page defined in javascript. Below is my grid code in javascript

 function LoadAllPanelUsers() {
                 
                 dataSource = new kendo.data.DataSource({
                     transport: {
                         read: {
                             url: "/Home/LoadAllUsers",
                             type: "POST",
                             dataType: "json"
                         },
                         update: {
                             url: "/Home/UpdateUser",
                             dataType: "json",
                             type: "POST"

                         },
                         destroy: {
                             url: "/Home/DeleteUser",
                             dataType: "json",
                             type: "POST"
                             
                         },
                         create: {
                             url: "/Account/InsertUser",
                             dataType: "json",
                             type: "POST"
                                        
                         },
                         parameterMap: function (options, operation) {
                             if (operation !== "read" && options.models[0]) {
                                 return options.models[0];
                             }
                         }
                     },
                     type: "json",
                     batch: true,
                     schema: {
                         model: {
                             id: "UserID",
                             fields: {
                                 UserID: { editable: false, nullable: true, type: "number" },
                                 UserNumber: { type: "number", validation: { required: true, max: 96} },
                                 UserDescription: { type: "string", validation: { maxLength: 31} },
                                 PartitionNumber: { editable: false, type: "number", defaultValue: "1", validation: { required: true} },
                                 AuthorityLevel: { type: "number", validation: { required: true }, defaultValue: 0 },
                                 UserCode: { type: "number", validation: { required: true, maxLength: 4, minLength: 4} },
                                 IsDeleted: { type: "bool" },
                                 IsEnabled: { type: "bool" }
                             }
                         },
                         data: "data",
                         total: "total"
                     }
                 });

                 var PanelDevices = [];
                 $("#rdgrd_AIB_UserResults").empty();
                 $("#rdgrd_AIB_UserResults").kendoGrid({
                     dataSource: dataSource,
                     height: 410,
                     selectable: "row",
                     
                     toolbar: ["create", "save", "cancel"],
                     columns: [
                            {
                                field: "UserNumber",
                                title: "User Number",
                                width: 150
                            },
                            {
                                field: "UserDescription",
                                title: "User Name",
                                width: 150
                            },
                            {
                                field: "PartitionNumber",
                                title: "Partition Number",
                                width: 150
                            },
                            {
                                field: "UserCode",
                                title: "User Code",
                                width: 150
                            },
                            {
                                field: "AuthorityLevel",
                               
                                title: "Authority Level",
                                width: 150
                            }
                    ],
                     editable: true,
                     navigatable: true
                 });
             }

when i insert the row , enter necessary values and click on save changes the controller action is called and the user is created in DB successfully. i return the same object after updating the new user id to the grid. below is my response body recieved from controller action.

  1. Request URL:
    http://localhost:60410/Account/InsertPanelUser
  2. Request Method:
    POST
  3. Status Code:
    200 OK
  4. Request Headersview source
    1. Accept:
      application/json, text/javascript, */*; q=0.01
    2. Accept-Charset:
      ISO-8859-1,utf-8;q=0.7,*;q=0.3
    3. Accept-Encoding:
      gzip,deflate,sdch
    4. Accept-Language:
      en-US,en;q=0.8
    5. Cache-Control:
      no-cache
    6. Connection:
      keep-alive
    7. Content-Length:
      110
    8. Content-Type:
      application/x-www-form-urlencoded
    9. Cookie:
      ASP.NET_SessionId=fjvgg5ehwlifhoukfi3zeupq
    10. Host:
      localhost:60410
    11. Origin:
      http://localhost:60410
    12. Pragma:
      no-cache
    13. Referer:
      http://localhost:60410/Home/Home
    14. User-Agent:
      Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17
    15. X-Requested-With:
      XMLHttpRequest
  5. Form Dataview sourceview URL encoded
    1. UserID:
      null
    2. UserNumber:
      43
    3. UserDescription:
      test234
    4. PartitionNumber:
      1
    5. AuthorityLevel:
      3
    6. UserCode:
      5428
    7. AccountID:
      0
  6. Response Headersview source
    1. Cache-Control:
      private
    2. Connection:
      Close
    3. Content-Length:
      254
    4. Content-Type:
      application/json; charset=utf-8
    5. Date:
      Mon, 28 Jan 2013 09:24:37 GMT
    6. Server:
      ASP.NET Development Server/10.0.0.0
    7. X-AspNet-Version:
      4.0.30319
    8. X-AspNetMvc-Version:
      4.0
Response data
{"ExtensionData":null,"AuthorityLevel":3,"Changed":false,"ChangedBy":null,"Defaulted":false,"IsDeleted":false, "IsEnabled":false,"MacPanelID":0,"PartitionNumber":1,"SortIndex":null,"UserCode":"5428","UserDescription":"test234", "UserID":66,"UserNumber":43} in the response data you can see that the user id is 66. this id is not getting updated in the grid data. following is my grid data after save changes

$("#rdgrd_AIB_UserResults").data('kendoGrid')
h.extend.init
  1. _currentjQuery.fn.jQuery.init[1]
  2. _dataArray[8]
    1. 0f
      1. AccountID0
      2. AuthorityLevel3
      3. PartitionNumber"1"
      4. UserCode5428
      5. UserDescription"test234"
      6. UserIDnull
      7. UserNumber43
      8. _eventsObject
      9. dirtyfalse
      10. idnull
      11. parentfunction (){return c}
      12. uid"a9eb1dab-0ce5-43a4-a1ef-2596db7b5c07"
      13. __proto__b
    2. 1f
    3. 2f
here in the above object you can see that id and userid is null

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 30 Jan 2013, 06:46 AM
Hello Narasimhan ,

As I suggested in the support ticket you opened about the same issue, you should return the record into an array named data as specified in your schema.data option.
Feel free to continue our conversation here or in the support ticket.

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Thomas
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or