Primefaces RowToggle-如何区分行扩展和行折叠? [英] Primefaces RowToggle - How to differentiate between Row Expansion and Row Collapse?

查看:120
本文介绍了Primefaces RowToggle-如何区分行扩展和行折叠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Prmefaces 3.5.我在数据表中使用RowToggler.每当单击RowToggle按钮时,我都会执行一些数据库访问操作,并使用访问的数据显示一个网格.

I am using Prmefaces 3.5. I use the RowToggler in a datatable. Whenever the RowToggle button is clicked, I use to do some database access operations and display a grid with the the accessed data.

只要单击切换按钮,就会调用下面的侦听器,在该侦听器中完成操作

Whenever the toggle button is clicked the below listener is called, in which the operations are done

<p:ajax event="rowToggle" listener="#{controller.onRowToggle}" 

但是问题在于调用此方法.不仅在展开行时会调用此方法,而且在折叠行时也会调用此方法.该行折叠时无需执行数据库操作,因此这是一项昂贵的操作.

But the problem lies in calling this method. Not only when the row is expanded, this method is called, but also when the row is collapsed. The database operations doesn't need to be done while the row is collapsed, and so this is turning out to be an expensive operation.

请提出如何知道该行是展开还是折叠的信息,以便我可以有条件地进行操作?

Please suggest how to know if the row is expanded or collapsed, so I could do the operations conditionally?

推荐答案

如果您要在扩展行时将RT仅设置为 ,则可以使用该方法:

If you want to make the RT only if the row is being expanded, this will work:

<p:ajax
    event="rowToggle"                                            
    onstart="return cfg.ext.params[0].name.indexOf('_rowExpansion') != -1"
    listener="#{fooViewModel.onRowToggle}"
/>

这篇关于Primefaces RowToggle-如何区分行扩展和行折叠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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