使用监听器上primefaces数据表执行排点击 [英] Execute row click using listener on primefaces datatable
问题描述
问题是短暂的。我创建了一个号码:数据表
,但在号码:列
其实我有一个 DIV
元素。不幸的是,数据表应该有选择行和DIV是不会合作;)。
因此,解决办法是手动调用它,div元素存在的onclick监听器,但我应该怎么称呼DataTable的rowSelection?有没有的Primefaces元素的功能有些列表?
Problem is short. I have created a p:datatable
but within the p:column
i actually have a div
element. Unfortunately the datatable should have selectable rows and the div just won't cooperate ;).
So the solution is to call it manually, on the div element there is onclick listener, but how should I call the rowSelection of the datatable? Is there some list of the functions of Primefaces' elements?
在code:
<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>
当然,这是一个简化版本,唯一的东西u需要。所以,问题是什么叫 DIV的onclick?
Of course it is a simplified version, only things u need. So the question is what to call in the div onclick?
推荐答案
在&LT;电话号码:dataTable的widgetVar&GT;
的 unselectAllRows()
和 selectRow(指数)
功能,这些功能正是你需要的。
the <p:dataTable widgetVar>
has unselectAllRows()
and selectRow(index)
functions which are exactly what you need.
<div onclick="friendscrollist.unselectAllRows(); friendscrollist.selectRow(#{findex})">
有遗憾的是没有提供这些功能的文档,但你可以在Chrome浏览器/萤火看到所有可用功能列表中自动完成列表中,当你进入 friendscrollist。
在JS控制台。下面是Chrome浏览器的屏幕:
There's unfortunately no documentation available for those functions, but in Chrome/Firebug you can see a list of all available functions in autocomplete list when you enter friendscrollist.
in JS console. Below is a screen from Chrome:
展望基于函数名JS源$ C $ C或常识应该告诉/提示你什么是这些功能的操作。
Looking in the JS source code or common sense based on the function name should tell/hint you what those functions do.
更新:我站在纠正,一些这些功能实际上是记录在 PrimeFaces 3.4用户指南。他们是章3.26数据表中的客户端API一节中,第146页。
Update: I stand corrected, a few of those functions are actually documented in PrimeFaces 3.4 User's Guide. They're in the "Client Side API" section of chapter 3.26 "DataTable", on page 146.
这篇关于使用监听器上primefaces数据表执行排点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!