javascript - How to get value of checked checkbox (in footer of jqgrid) and send to controller? -


i have checkbox in footer of jqgrid , want send value of checkbox controller when click on button(send command). enter image description here

when row selected , click button send command, in addition value, check box sent (selected or not selected) code:

 .jqgrid('navbuttonadd', '#pager',                        {                        caption: "send command ", buttonicon:"ui-  icon-signal-diag", title: "send command ",                             onclickbutton: function () {                                 var selrow =    jquery("#list").jqgrid('getgridparam', 'selarrrow');  //get selected rows                                 var datatosend = json.stringify(selrow);                                 if (selrow == 0) {                                     // display error message because no row selected                                     $.jgrid.viewmodal("#" + 'alertmod_' + this.p.id,                                         { gbox: "#gbox_" +   $.jgrid.jqid(this.p.id), jqm: true });                                     $("#jqg_alrt").focus();                                 }                                 else {                                     $.ajax({                                         url: '@url.action("index", "addsms")',                                         type: 'post',                                         contenttype: 'application/json; charset=utf-8',                                         data: datatosend,                                         datatype: 'json',                                         success: function (result) {                                             alert('success');                                         }                                     });                                 }                             }                         })         $("#pager_left table.navtable tbody tr").append( // here 'pager' part or #pager_left id of pager '<td><div><input type="checkbox" class="mymultisearch" id="withsetting" />setting </div></td>'); 

i can send data of row don't know how send value of checkbox???

you send url parameter. change:

url: '@url.action("index", "addsms")', 

to

url: '@url.action("index", "addsms")' + '?cbchecked=' + $("input.mymultisearch").is(":checked"), 

then should able update index in addsms controller to:

public actionresult index(long[] selrow, bool cbchecked)  {      if (cbchecked)      {         //this should run if checkbox has been checked     } //...... 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -