Suave Nti
Suave Nti

Reputation: 3757

Attach onSelectRow event to jqGrid Formatter

I have a jqGrid with Radio Button formatter for each row in the jqGrid. Everything works fine

My Cell Formatter for the RadioButton looks like this

formatter: function radio(cellValue, option) {
    return '<input type="radio" name="radio_' + option.gid + '" value=' +
           cellValue + '/>';
}

Now am trying to attach onSelectRow event to this RadioButton formatter i.e.., When ever I click a Radio Button it should give me the Row Id Value. How can I do this? Is it possible?

Thanks

Upvotes: 0

Views: 2878

Answers (1)

Oleg
Oleg

Reputation: 222017

You can use beforeSelectRow callback like

beforeSelectRow: function (rowid, e) {
    if ($(e.target).is('input[type="radio"]')) {
        alert('The radio button are selected in the row with id=' + rowid);
    }
    return true; // allow row selection
}

to catch click event on the radio button. See the demo.

You can additionally implement selection of the radio button if the user select the row somewhere (see the demo the answer).

Upvotes: 1

Related Questions