radio button column mutually exclusive within all grid rows for this radio column using JqGrid?(单选按钮列在使用 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 .
谢谢.
推荐答案
如果我理解你是正确的,你可以使用自定义格式化程序.如果您包含的所有按钮都具有相同的 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 的此单选列的所有网格行中互斥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:单选按钮列在使用 JqGrid 的此单选列的所有网格行中互斥?


- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Fetch API 如何获取响应体? 2022-01-01