一行可以在< p:dataTable> [英] How at a time one row can expand in <p:dataTable>?

查看:127
本文介绍了一行可以在< p:dataTable>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有一个< p:datatable> 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中测试了它,它的工作正常)以下解决方案当行被展开时调用JavaScript函数。当单击第二行并且还有另一个展开的行时,它将触发单击事件,这将反过来折叠先前打开的行。

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:



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>

这篇关于一行可以在&lt; p:dataTable&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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