如何使用单选按钮获取选定的icefaces数据表行? [英] How to get selected icefaces datatable row using radiobutton?

查看:73
本文介绍了如何使用单选按钮获取选定的icefaces数据表行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用单选按钮在icefaces数据表中选择一行?

How can I select a row in icefaces datatable using radio button?

我尝试了以下方法

<h:selectOneRadio styleClass="none" valueChangeListener="#{bean.setSelectedItem}"
                onclick="dataTableSelectOneRadio(this);">
                <f:selectItem itemValue="null" />
            </h:selectOneRadio>

还有我的JavaScript

And my javascript

function dataTableSelectOneRadio(radio) {
    var id = radio.name.substring(radio.name.lastIndexOf(':'));
    var el = radio.form.elements;
    for (var i = 0; i < el.length; i++) {
        if (el[i].name.substring(el[i].name.lastIndexOf(':')) == id) {
            el[i].checked = false;
        }
    }
    radio.checked = true;
}

在另一篇文章中,我得到一个答案,我应该将form.name替换为form.id.但是在那之后我得到了错误

In another post I got an answer that I should replace form.name with form.id. However after that I am getting error

radio.form is undefined 
var elements = radio.form.elements;

有人可以帮助我如何解决此问题.

Could someone help me how to resolve this issue.

我想使用单选按钮在icefaces数据表中选择一行.

I would like to select one row in icefaces datatable using radio button.

任何帮助都是非常重要的.

Any help is highly appreciable.

谢谢

发布我生成的html源代码

Posting my generated html source

请参见此处是单选按钮的jsf代码

See here is jsf code for radio button

<h:selectOneRadio  valueChangeListener="#{bean.setSelectedItem}"
id="reqselect" onclick="dataTableSelectOneRadio(this);">
<f:selectItem itemValue="null" />
</h:selectOneRadio>

我为在正确的html源中发布内容表示由衷的歉意,我在测试其他内容,因此发布了错误的源代码.下面粘贴的是我正确的html源代码,请查看是否可以找到某些内容.

My heartfelt apologies for posting in correct html source, I was testing some thing else and thus wrong source got posted. Pasted below is my correct html source, kindly see if you could find something.

推荐答案

您应使用带有散布布局的ice:selectOneRadio:

You should use the ice:selectOneRadio with spread layout:

<ice:selectOneRadio id="myRadioId" layout="spread" ... /> 
<ice:dataTable ... >
    <ice:column ...>
        <ice:radio for="myRadioId" ... />
    </ice:column>
    ...
</ice:dataTable>

这篇关于如何使用单选按钮获取选定的icefaces数据表行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆