【发布时间】:2015-12-23 23:53:17
【问题描述】:
我使用素面, 我的表有超过 75 列, 当我想复制行并粘贴到同一个表中时怎么办(当然改变后的PK)
【问题讨论】:
标签: primefaces datatable copy-paste
我使用素面, 我的表有超过 75 列, 当我想复制行并粘贴到同一个表中时怎么办(当然改变后的PK)
【问题讨论】:
标签: primefaces datatable copy-paste
感谢所有回答 但我有一个小解决方案:
在“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
【讨论】:
您可以使用<p:hotkey>(捕获您的复制和粘贴)以及<p:dataTable> 的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
}
}
【讨论】:
你不能开箱即用。我能想到的唯一一件事是创建一个上下文菜单和/或拦截 ctrl-v/c 键并调用一些支持 bean 的方法,这些方法都会为您完成。但这将是一个复杂的解决方案为您创建。
【讨论】: