简体   繁体   English

如何在数据表中使用PrimeFaces p:droppable?

[英]How to use PrimeFaces p:droppable inside datatable?

There is business need to categorize items. 有业务需要对项目进行分类。 Best idea seems to be dragdrop items from one list into list of categories. 最好的想法似乎是将一个列表中的项目拖放到类别列表中。 Number of categories can vary so p:dataTable is used. 类别数可以变化,因此使用p:dataTable。 Ajax request is sent but onDrop method is not called from inside dataTable. 发送Ajax请求但不从dataTable内部调用onDrop方法。 When Removing datatable and column and having outputpanels statically then onDrop is called? 删除数据表和列并静态输出窗口时,会调用onDrop吗?

How to best drag and drop items into dynamically changing categories? 如何最好地将项目拖放到动态变化的类别中?

        <h:form prependId="false">
            <h:panelGrid columns="2">
                <p:dataTable id="itemstable" value="#{categoryBean.items}" var="item">
                    <p:column>
                        <p:outputPanel id="itemrow">
                            <h:outputText value="#{item}"></h:outputText>
                        </p:outputPanel>
                        <p:draggable for="itemrow"></p:draggable>
                    </p:column>
                </p:dataTable>

                <p:dataTable value="#{categoryBean.categories}" var="cat">
                    <p:column>
                        <p:outputPanel id="cats1">
                            <h:outputText value="category1"></h:outputText>
                        </p:outputPanel>
                        <p:droppable for="cats1"
                                     dropListener="#{categoryBean.onDrop}"
                                     tolerance="pointer"
                                     activeStyleClass="slotActive"
                                     datasource="itemstable">
                        </p:droppable>
                    </p:column>
                </p:dataTable>
            </h:panelGrid>
        </h:form>

There is a bug in PrimeFaces, when <p:droppable> is nested in any data repeating element the dropListener does not get called. PrimeFaces中存在一个错误 ,当<p:droppable>嵌套在任何数据重复元素中时,dropListener不会被调用。 I also tried using the Facelets repeat tag <ui:repeat> but the dropListener was not called just like dragging to the <p:dataTable> . 我也尝试使用Facelets重复标记<ui:repeat>但是没有调用dropListener就像拖动到<p:dataTable>

In the PrimeFaces showcase all of the drag an drop examples have static droppable areas. 在PrimeFaces中展示了所有拖拽,下拉示例具有静态可放置区域。
PrimeFaces ShowCase PrimeFaces ShowCase

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM