asp.net mvc - MVC | Kendo Grid | Pass the data from View to the controller -


i using kendoui grid populated data. grid has 1 template column, of check-box , other columns client template includes text-box in it.

i need pass data of rows, selected using check-box, controller action.

the updated values in text-box should passed controller.

let me know if has solution same.

this grid

@(html.kendo().grid<mmm.lumos.entities.customentities.testplantestpointmappingviewmodel>()                         .name("atpgrid")                         .columns(columns =>                         {                             columns.bound(p => p.isselected).clienttemplate("<input type='checkbox' value='#= isselected #' " + "# if (isselected) { #" + "checked='checked'" + "# } #" + "/>").width(40);                             columns.bound(p => p.testpointname).filterable(false).width(60);                             columns.bound(p => p.passthreshold).clienttemplate(html.kendo().integertextbox().name("mp_#=testpointid#").min(0).htmlattributes(new { value = "#=passthreshold#", style = "width: 50px;" }).toclienttemplate().tohtmlstring()).width(60);                             columns.bound(p => p.failthreshold).clienttemplate(html.kendo().integertextbox().name("mp_#=testpointid#").min(0).htmlattributes(new { value = "#=failthreshold#", style = "width: 50px;" }).toclienttemplate().tohtmlstring()).width(60);                          })                         .scrollable()         //.htmlattributes(new { style = "height:430px;" })                         .datasource(datasource => datasource                             .ajax()                             .pagesize(20)                             .read(read => read.action("atpgrid_read", "testplan"))                          )                     ) 

i have submit button

<input type="submit" name="add" formmethod="post" onclick="postdata()" value="add" /> 

javascript function

<script>     function postdata() {                 var griddata = $("#atpgrid").data("kendogrid");          alert(json.stringify({ griditems: griddata.datasource.view() }));          //$.ajax(         //       {         //           type: 'post',         //           url: '/configuration/testplan/add',         //           datatype: 'json',         //           contenttype: "application/json; charset=utf-8",         //           data: json.stringify({ griditems: griddata.datasource.view() }),         //           success: function (result) {         //               alert('success');         //           }         //       });     }  </script> 

i need values of grid on click of add button. can see have client template columns, check-box , text-box in grid.

i need values text-box , pass controller.

it great if selected using check-box should passed controller.

i not sure whether there simple way of passing values view controller in kendo ui grid. have followed below way in third party mvc grid pass checkbox values. can bind function button click event. long simple operation. may useful can optimize needs.

function postdata(sender, args) {         var tempcheckedrecords = new array();         var gridobj = $find("grid1"); // getting grid object. modify kendoui grid.         if (sender.checked == true) {             ... //retrieve records here             tempcheckedrecords.push(records[0]); // pass selected records in array           }          var temprecords = new array();         $.each(tempcheckedrecords, function (index, element) {             var record = {};             record["column0"] = element.isselected; // column names in grid             record["column1"] = element.testpointname; // can text box values in element.             record["column2"] = element.passthreshold;             temprecords.push(record);          });          var params = {};         var visiblecolumns = gridobj.get_visiblecolumnname();         $.each(temprecords, function (i, record) {             $.each(visiblecolumns, function (j, value) {                 params["test[" + i + "]." + this] = record[value];             });         });          $.ajax({             type: 'post',             url: "/configuration/testplan/add",             datatype: 'json',             data: params,             success: function (data) {                 return data;             }         });        } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -