【问题标题】:Radio Buttons in a jqGridjqGrid中的单选按钮
【发布时间】:2016-09-22 04:40:31
【问题描述】:

基本上,我试图在 jqGrid 中包含单选按钮。 我可以看到我们可以为此使用自定义格式化程序。 以下是我的代码,它没有告诉我选择了哪个单选按钮/或者它是否被选中。

该值始终为“未定义”。

// The custom formatter definition
function radio(value, options, rowObject){
   var radioHtml = '<input type="radio" value=' + value + ' name="radioid" />';
   return radioHtml;
}

// Snippet of the colModel in jqGrid definition
colModel:[
    {name:'select', label:'Select', width: 60, align:'center', edittype:'custom', 
     editable:true, formatter: radio},
    {name:'name', label: 'Source Disk Volume', width: 170}],

// The method called on submit
function evaluate() {
    // try 1
    alert('val: '+$("[name='radioid']:checked").val()); 

    // try 2
    tried accessing the checked radio button through simple javascript 
}

请帮助我访问用户选择的单选按钮的值。

【问题讨论】:

    标签: javascript jqgrid radio


    【解决方案1】:
    gridComplete: function () {
        $("td[aria-describedby=jqgridName_select] input[type='radio']").click(function () {
            alert($(this).val());
        });
    }
    

    【讨论】:

    • 欢迎来到 Stack Overflow!你能解释一下这段代码的作用,而不仅仅是发布代码吗?
    猜你喜欢
    • 2011-04-14
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    • 1970-01-01
    • 2011-03-16
    相关资源
    最近更新 更多