如果用户单击特定行的这一列,那么如何创建一个带有特殊单选按钮列的网格,然后只有这个单选按钮被选中,就像有一个单选组垂直分布在这一列网格中一样??
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 .
谢谢.
如果我理解你是正确的,你可以使用自定义格式化程序.如果您包含的所有按钮都具有相同的 name
属性,您将拥有您需要的行为
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 的此单选列的所有网格行中互斥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!