Xpages get index of repeat in CSJS

末鹿安然 提交于 2019-12-13 00:38:05

问题


I want to get the index of an repeat in CSJS. I tried to get the repeatID and then get the value, but it is not working.

var r="view:_id1:repeat1:"
var val=document.getElementById(r).value.toString();

回答1:


Create a computed text like this:

  <xp:text
        escape="true"
        id="computedFieldIndexVar"
        tagName="input">

        <xp:this.attrs>
            <xp:attr
                name="type"
                value="hidden">
            </xp:attr>
            <xp:attr
             name="value"
             value="#{javascript:var rp:com.ibm.xsp.component.xp.XspDataIterator = getComponent('repeat1');rp.getRowCount()}">
             </xp:attr>
        </xp:this.attrs>
    </xp:text>

You can then access the field in CSJS:

var r="view:_id1:computedFieldIndexVar"
var val=document.getElementById(r).value

The repeat control has the id repeat1.



来源:https://stackoverflow.com/questions/25805075/xpages-get-index-of-repeat-in-csjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!