radio button column mutually exclusive within all grid rows for this radio column using JqGrid?

ぐ巨炮叔叔 提交于 2019-12-17 19:26:14

问题


How to create a grid with one special column of radio buttons in such a way if user click on this column of a particular row then only this radio button gets selected like if there is a radio group spread across this column of grid vertically ??

I am looking for this solution in JqGrid (jquery) specifically .

Thanks.


回答1:


If I understand you correct you can just use custom formatter. If all the buttons which you included has the same name attribute you will have the behavior which you need

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

After creating the column with radio buttons you will receive many other questions how to synchronize other functionality of jqGrid with the radio buttons. In the following example I show you how you can check the radio button on selecting the row:

beforeSelectRow: function (rowid, e) {
    var radio = $(e.target).closest('tr').find('input[type="radio"]');
    radio.attr('checked', 'checked');
    return true; // allow row selection
}

See the demo here.



来源:https://stackoverflow.com/questions/7401253/radio-button-column-mutually-exclusive-within-all-grid-rows-for-this-radio-colum

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!