问题描述
在我的应用程序中,我有一个 和
rowExpansion
列.我需要一次打开一行.如果有人试图扩展第二行,剩余的第一行将被扩展,那么将生成一条消息,说首先关闭扩展的行,然后打开另一行
.
In my application I have a <p:datatable>
with rowExpansion
column. I have a requirement to open a single row at a time. If anyone tries to expand second row, remaining first row expanded then one message will be generated saying First close the expanded row and then open another row
.
如何实现?任何指针都会对我很有帮助.谢谢
How this can be implemented ? Any pointer will be very helpful to me. Thanks
推荐答案
您可以使用(我已经在 mojarra 2.1.20 和 Primefaces 3.5 中对其进行了测试,并且工作正常)以下解决方案,该解决方案在行为扩大了.当点击第二行,并且有另一行展开时,会触发click
事件,依次折叠之前打开的行.
You can use (I have tested it in mojarra 2.1.20 and Primefaces 3.5 and it works fine) the following solution which calls a JavaScript function when the row is expanded. When clicking on a second row, and there is another expanded row, it will trigger a click
event, which will in turn collapse the previously opened row.
<p:ajax event="rowToggle" onstart="test();"/>
Javascript:
<script type="text/javascript">
function test(){
var i = $('.ui-row-toggler.ui-icon-circle-triangle-s').length;
if(i == 1){return;}
$('.ui-row-toggler.ui-icon-circle-triangle-s').trigger('click');
}
</script>
这篇关于如何在 <p:dataTable> 中一次扩展一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!