Note that there are some explanatory texts on larger screens.

plurals
  1. POChange JQGrid Cell value on Button Click
    primarykey
    data
    text
    <p>I am using jqgrid in asp.net webforms. I have a column which name is Actions, in which I have button Add I want that when I click on add button, then cell value should be changed. Like I have button in this cell, when I click on add button, then it should change with text. Please, guide me. Code is given below which i am using.</p> <pre><code>&lt;table id="jQGridDemo"&gt; &lt;/table&gt; &lt;div id="jQGridDemoPager"&gt; &lt;/div&gt; </code></pre> <p> </p> <pre><code>jQuery("#jQGridDemo").jqGrid({ url: 'HttpHandlers/CustomersList.ashx', datatype: "json", colNames: ['Opted-In', 'Name', 'Email', 'Filter Matches', 'Customer Id','Actions'], colModel: [ { name: 'OptedIn', index: 'OptedIn', width: 40,align:'center', stype: 'text', formatter: OptedInValue }, { name: 'CustomerName', index: 'CustomerName', width: 90, stype: 'text', sortable: true }, { name: 'CustomerEmail', index: 'CustomerEmail', width: 110, stype: 'text', sortable: true }, { name: 'FilterLetter', index: 'FilterLetter', width: 60 }, { name: 'CustomerId', index: 'CustomerId', width: 60, hidden: true }, { name: 'Actions', index: 'Actions',editable:true, width: 60,align:'center',formatter: ButtonValue } ], width: 600, height:300, rowNum: 30, mtype: 'GET', loadonce: true, rowList: [30, 60, 90], pager: '#jQGridDemoPager', sortname: 'OptedIn', viewrecords: true, sortorder: 'asc', caption: "Customer List" }); function ButtonValue(cellvalue, options, rowObject) { var filterLetter = rowObject.FilterLetter; var link = ''; if (filterLetter == " A") { link = '&lt;button type="button" onclick=addGridCustomer(' + rowObject.CustomerId +')&gt;Add&lt;/button&gt;'; } else { link = '&lt;div id="rowelder"&gt;&lt;button type="button" onclick=removeGridCustomer(' + rowObject.CustomerId + ',' + options.rowId +')&gt;Remove&lt;/button&gt;&lt;/div&gt;'; } return link; } function OptedInValue(cellvalue, options, rowObject) { var optedIn = rowObject.OptedIn; var link = ''; if (optedIn == true) { link = '&lt;img title="View ' + rowObject.CustomerName + ' ' + '" src="/images/icn_alert_success.png" /&gt;'; } else if (optedIn == false) { link = '&lt;img title="View ' + rowObject.CustomerName + ' ' + '" src="/images/icn_alert_error.png" /&gt;'; } return link; }; function removeGridCustomer(id,rowId) { debugger var rowData = $('#jQGridDemo').jqGrid('getRowData', rowId); rowData.Actions = '12321'; $('#jQGridDemo').jqGrid('setRowData', rowId, rowData); $('#&lt;% = hdCustomer.ClientID %&gt;').val($('#&lt;% = hdCustomer.ClientID %&gt;').val() + id + ','); UpdateFiltersForCusRemove(id); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload