【问题标题】:primefaces dataTable: how to copy paste rowprimefaces dataTable:如何复制粘贴行
【发布时间】:2015-12-23 23:53:17
【问题描述】:

我使用素面, 我的表有超过 75 列, 当我想复制行并粘贴到同一个表中时怎么办(当然改变后的PK)

【问题讨论】:

    标签: primefaces datatable copy-paste


    【解决方案1】:

    感谢所有回答 但我有一个小解决方案:

    在“list.xhtml”文件和上下文菜单面板中添加以下行:

    <p:menuitem value="Copy" onclick="document.getElementById('CustomerListForm:copyButton').click();" icon="ui-icon-copy"/>
    

    在文件末尾加上其他按钮:

    <p:commandButton id="copyButton"   style="visibility: hidden; icon="ui-icon-copy"   value="Copy" update=":CustomerCreateForm" oncomplete="PF('CustomerCreateDialog').show()"/>
    

    了解更多click here

    【讨论】:

    • 这个问题的答案如何?
    • 这仍然不是原始问题的答案。 Q 中没有 list.xhtml,答案中指向 Youtube 视频(法语!!!)的链接不符合 Stackoverflow 的“规则/指南”等...
    【解决方案2】:

    您可以使用&lt;p:hotkey&gt;(捕获您的复制和粘贴)以及&lt;p:dataTable&gt;selectionMode 属性

    你可以试试:

    <h:form>
       <p:hotkey bind="ctrl+c" actionListener="#{Bean.copy}"/>
       <p:hotkey bind="ctrl+s" actionListener="#{Bean.paste}"/>
       <p:dataTable id="dceTable" value="#{Bean.list}"
                    var="row" selection="#{Bean.selection}"
                    rowKey="#{row.seqNo}" >
          <p:column selectionMode="multiple" style="width:30px;text-align:center" />
          ... insert your columns here
       </dataTable>
    </h:form>
    

    和你的支持 bean:

    @Named("DCEBean")
    @ViewScoped
    public class Bean implements Serializable {
    
    public void copy(){
    // to copying codes like change PK
    }
    
    public void paste(){
    // insert in your copied rows
    }
    
    }
    

    【讨论】:

      【解决方案3】:

      你不能开箱即用。我能想到的唯一一件事是创建一个上下文菜单和/或拦截 ctrl-v/c 键并调用一些支持 bean 的方法,这些方法都会为您完成。但这将是一个复杂的解决方案为您创建。

      【讨论】:

      • 谢谢你的回答,但你能举个例子吗?
      • 请阅读我回答的最后一句话。如果你分解这个“答案”,你可以在 stackoverflow 上找到每个部分的解决方案。
      猜你喜欢
      • 2014-09-07
      • 1970-01-01
      • 1970-01-01
      • 2014-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多