【问题标题】:Primefaces contextMenu for multiple dataTables?多个数据表的Primefaces contextMenu?
【发布时间】:2016-01-12 09:40:42
【问题描述】:

是否可以有一个属于多个数据表的 contextMenu?如果有,怎么做?

【问题讨论】:

    标签: primefaces datatable contextmenu


    【解决方案1】:

    我从来没有这样做过,但我会这样尝试:

    <p:dataTable id="table1" ...>
        <p:ajax event="contextMenu" update="myContextMenuId" listener="#{myContextMenuBL.initContextMenuForTable('table1')}" oncomplete="PF('myContextMenuWidgetVar').show(currentEvent);" />
    </p:dataTable>
    
    <p:dataTable id="table2" ...>
        <p:ajax event="contextMenu" update="myContextMenuId" listener="#{myContextMenuBL.initContextMenuForTable('table2')}" oncomplete="PF('myContextMenuWidgetVar').show(currentEvent);" />
    </p:dataTable>
    
    <p:contextMenu id="myContextMenuId" widgetVar="myContextMenuWidgetVar">
        <p:menuitem value="entry 1"  />
        ...
    </p:contextMenu>
    

    在您的上下文菜单控制器中,您可以通过initContextMenuForTable() 的调用知道菜单正在为哪个表“工作”。如果您想要为每个表提供不同的上下文菜单,这将有点困难。但是为什么您不仅为每个表使用单独的上下文菜单呢?

    【讨论】:

    • 酷我试试看。我确实尝试为每个表使用单独的上下文菜单,但只有最终呈现的表才有功能齐全的上下文菜单...
    • 我不明白您所说的“只有最终呈现的表格才会有一个功能齐全的上下文菜单”是什么意思。我认为使用contextMenu 指向表的for 属性为每个表创建单独的菜单会更容易。
    • 是的,这也是我的逻辑。 However, despite pointing a context menu to a specific table, only the last table had a context menu which, when an item was selected, would render the appropriate page.也许与延迟加载有关?
    • 好的,试试这个。我认为以前我命名的东西有点错误。感觉相当肯定我现在已经正确地指出了彼此,我有一种奇怪的行为,有时一个表的上下文菜单可以工作而其余的失败,有时另一个表的上下文菜单可以工作而其余的失败......有点奇怪
    猜你喜欢
    • 2013-01-08
    • 2013-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多