Ata*_*ais 4 javascript ajax jsf primefaces jsf-2
问题很短暂.我已经创建了一个,p:datatable但p:column我实际上有一个div元素.不幸的是,数据表应该有可选行,而div只是不合作;).所以解决方法是手动调用它,在div元素上有onclick监听器,但是我应该如何调用datatable的rowSelection?是否有一些Primefaces元素的功能列表?
代码:
<p:dataTable var="user" value="#{rec.friends}" rowKey="#{user.id}" widgetVar="friendscrollist"
rendered="#{not empty rec.friends}" scrollable="true" rowIndexVar="findex"
scrollHeight="500" scrollWidth="220" selectionMode="single" selection="#{rec.chosenFriend}" styleClass="friendscroll">
<p:column width="198" id="friend#{findex}">
<div class="friendlist" onclick="friendscrollist.clickRow(#{findex})" />
</p:column>
<p:ajax update=":leftform" event="rowSelect" />
<p:ajax update=":leftform" event="rowUnselect" />
</p:dataTable>
Run Code Online (Sandbox Code Playgroud)
当然它是一个简化版本,只有你需要的东西.所以问题是该怎么称呼div onclick?
Bal*_*usC 12
在<p:dataTable widgetVar>具有unselectAllRows()和selectRow(index)功能,这些功能正是你需要的.
<div onclick="friendscrollist.unselectAllRows(); friendscrollist.selectRow(#{findex})">
Run Code Online (Sandbox Code Playgroud)
遗憾的是,没有可用于这些功能的文档,但在Chrome/Firebug中,当您进入friendscrollist.JS控制台时,您可以在自动完成列表中看到所有可用功能的列表.以下是Chrome的屏幕:

查看基于函数名称的JS源代码或常识应告诉/提示您这些函数的作用.
更新:我已经纠正了,其中一些功能实际上记录在PrimeFaces 3.4用户指南中.它们位于第3.26章"DataTable"的第146页的"客户端API"部分.
| 归档时间: |
|
| 查看次数: |
19191 次 |
| 最近记录: |