c# - Update command not firing datasource's update transport method - Kendo Grid -


hi returning data table stored procedure used bind grid. no identity field returned data table. in scenario please me out firing 'update', 'destroy' , 'create'.

this controller method,

 public jsonresult employee_read([datasourcerequest]datasourcerequest request)     {              datatable dt = new datatable();             using (sqlconnection con = new sqlconnection(configurationmanager.connectionstrings["manualconn"].connectionstring))             {                 var command = new sqlcommand("usp_fetchuserdetails", con);                 command.commandtype = commandtype.storedprocedure;                      con.open();                     sqldataadapter da = new sqldataadapter(command);                     da.fill(dt);                     system.web.script.serialization.javascriptserializer serializer = new system.web.script.serialization.javascriptserializer();                     list<dictionary<string, object>> rows = new list<dictionary<string, object>>();                     dictionary<string, object> row;                     foreach (datarow dr in dt.rows)                     {                         row = new dictionary<string, object>();                         foreach (datacolumn col in dt.columns)                         {                             row.add(col.columnname, dr[col]);                         }                         rows.add(row);                     }                      return json(rows, jsonrequestbehavior.allowget);               }     //     }      } 

this part of view:

<script type="text/javascript">  var grid = $("#grid").data("kendogrid"); var employee = kendo.data.model.define({     id: "userdetailsid",     fields: {         "userdetailsid": { type: "number" },         "name": { type: "string" },         "department": { type: "string" },         "role": { type: "string" },         "email": { type: "string" },       } });  var datasource = new kendo.data.datasource({     transport: {         read: {             url: '@url.action("employee_read", "usersummary")',             datatype: "json",             cache: false,             type: 'get',             //data: {             //    test: $("#names").val()             //}         },         destroy:          //function (e) {                   {             url: '@url.action("update_details", "usersummary")',                type: "post",           //  datatype: "json",             //data: {             //    daky: $("#names").val(),             //    diky: $("#btntxt").val()             //}         },         create: {             url: '@url.action("update_details", "usersummary")',             type: "post",            // datatype: "json",             //cache: false,             //data: {             //    aky: $("#names").val(),             //    iky: $("#btntxt").val()             //}         },         update:                  {             url: '@url.action("update_details", "usersummary")',             type : "post"             //data: {             //  aky: $("#names").val(),             //  iky: $("#btntxt").val()             //       }         }               },     error: function (e) {         // handle error         alert("status: " + e.status + "\n" + e.errorthrown);     },     pagesize: 5,                 schema: {                     model: {                         id: "userdetailsid",                         model: employee                     }                 }             });              $("#grid").kendogrid({                 datasource: datasource,                 editable: "inline",                 //toolbar: ["create", "save"],                 autobind: true,                 pageable: true,                 columns: [                     //{                     //    field: "userdetailsid",                     //    title: "userdetailsid",                     //    width: "50px",                      //},                     {                                 field: "name",                                 title: "name",                                 width: "75px",                                 template: "<input id='name' type='text' value='#: name #' readonly> </input>",                                 editable:false,                             },                             {                                 field: "department",                                 title: "department",                                 width: "50px",                                 editor: ddlfetchdepartments                               },                             {                                 field: "role",                                 title: "role",                                 width: "50px",                                 editor: ddlfetchroles                              },                             {                                 field: "email",                                 title: "email",                                 width: "100px",                                 template: "<input type='text' id='email' size='35' value='#:email#' readonly> </input>",                                 editable:false,                             },                               {                                  command: ["edit", "destroy"], title: "&nbsp;", width: "75px"                              },                              { command: { text: "custom edit", click: showdetails },title: " ", width: "60px" }                  ],             });                function showdetails(e) {                  e.preventdefault();                 //debugger;                 var dataitem = this.dataitem($(e.currenttarget).closest("tr"));                 alert("view details\n name : " + dataitem.name+"\nuserdetailsid : "+dataitem.userdetailsid);                  @{             //   ((mockproject.controllers.usersummarycontroller)this.viewcontext.controller).update_details();                 }              }              function ddlfetchdepartments(container, options) {                  $('<input name="departments" data-bind="value:' + options.field + '"/>')                      .appendto(container)                      .kendodropdownlist({                          datatextfield: "deptname",                          datavaluefield: "deptid",                          autobind: false,                          datasource: new kendo.data.datasource({                              transport: {                                  read: {                                      url: '@url.action("fetchdepartments", "usersummary")',                                     type: 'get',                                     datatype: "json"                                  },                                 schema: {                                     model: {                                         id: "deptid",                                         value: "deptname"                                     }                                  }                              }                          })                      });             }                 function ddlfetchroles(container, options) {                      $('<input name="roles" data-bind="value:' + options.field + '"/>')                          .appendto(container)                          .kendodropdownlist({                              datatextfield: "rolename",                              datavaluefield: "roleid",                              autobind: false,                              datasource: new kendo.data.datasource({                                  transport: {                                      read: {                                          url: '@url.action("fetchroles", "usersummary")',                                         type: 'get',                                         datatype: "json"                                      },                                      schema: {                                          model: {                                              id: "roleid",                                             value: "rolename"                                          }                                      }                              }                             })                         });                 }             @*@{                 ((homecontroller)this.viewcontext.controller).method1();             }*@     </script> <br/>   &nbsp; <button type="button" id="btn_adduser" > &nbsp;add user</button>  &nbsp;  &nbsp; <input type="submit" style="visibility:hidden" name="btn_save" class="k-button k-button-icontext" id="btn_save" value="save" onclick="savedatatodb()" />  <script type="text/javascript">      function savedatatodb() {      }      $('#btn_adduser').click(function () {          document.getelementbyid('btn_save').style.visibility = "visible";         $('#grid').data('kendogrid').addrow();     });      function onedit(e) {         //custom logic default value         var name = $("#addsinglesuppliment").text();          // if addition         if (e.model.isnew()) {             //set field             e.model.set("name", name); // name: grid field set         }     }  </script>   <script>     $(document).ready(function () {         $("#btn_adduser").kendobutton({             spritecssclass: "k-icon iconplus"         });      }); </script>   <style scoped>     .k-button .k-image {         height: 16px;     }      .demo-section {         width: 500px;     }      .iconplus {         background-image: url("../content/icons/plus.png");         background-size: contain;         /*background-position: 0 -64px;         align-content: flex-start;         align-self: auto;*/     } </style> 


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -