Detecting Checkbox Event In Jqgrid Cell
Solution 1:
First of all you should not use 'cb'
as the name
of the column because it is reserved column name. Other two reserved column names are 'subgrid'
and 'rn'
. Just use any other name if you don't want to have strange problems.
You have to bind the click
event manually to your event handler. To do this you have some options.
You can bind click
to all checkboxes inside of the loadComplete
callback. See the answer where are used jQuery to enumerate all checkboxes. Another answer shows a little more effective way which use the fact that DOM of <table>
, <tr>
and <td>
supports already native implemented rows
and cells
collections. So you can access <td>
by this.rows[iRow].cells[iCol]
inside of loadComplete
.
One more way will be to use custom formatter instead of formatter: 'checkbox'
and use onclick
attribute for binding.
UPDATED: If you use local data in the grid you have to update the corresponding value manually. See the answer for example. It describes how to use getLocalRow
or use data
and _index
internal parameters of jqGrid.
To get id
of the row on which the user clicked you can use target of the current event $(e.target).closest("tr.jqgrow").attr('id')
.
Post a Comment for "Detecting Checkbox Event In Jqgrid Cell"