使用JqGrid的此无线电列的所有网格行内的单选按钮列是否互斥? [英] radio button column mutually exclusive within all grid rows for this radio column using JqGrid?
问题描述
如果用户点击特定行的这一列,那么只有这个单选按钮被选中,就好像有一个广播组垂直穿过此列的网格一样,如何以这种方式创建一个具有单选按钮的特殊列的网格
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 ??
我特别在JqGrid(jquery)中寻找这个解决方案。
I am looking for this solution in JqGrid (jquery) specifically .
谢谢。
推荐答案
如果我理解您正确,您可以使用自定义格式化程序。如果您包含的所有按钮具有相同的名称
属性,则您将具有您需要的行为
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 + '" />';
}
使用单选按钮创建列后,您将收到许多其他问题如何同步jqGrid的其他功能与单选按钮。在下面的例子中,我向你展示了如何在选择行时检查单选按钮:
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
}
查看演示这里。
这篇关于使用JqGrid的此无线电列的所有网格行内的单选按钮列是否互斥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!