繁体   English   中英

数据表行保持选中/突出显示,其中selectionMode =“ single”

[英]datatable row remains selected/highlighted where selectionMode=“single”

我一直在运行Primefaces 3.0,没有问题,现在尝试升级到3.4.x-我已经尝试过3.4、3.4.1和3.4.2,并且在所有3种情况下都出现了此问题-基本上是针对带有当我单击一行时,无论我选择了多少其他行,selectionMode =“ single”选项均保持选中状态。 同时,我非常确定单击行时未设置selection =“#{databrowser.selectedData}”变量。 该表已完全填充,并且没有2行所有列中的数据都完全相同。 经过测试,在Chrome和Firefox中都会发生。 我找不到发布的任何类似问题-想知道是否有人遇到过此问题?

除了引用的元素之外,还有我使用的3.0代码:

<p:layoutUnit position="center" resizable="true" header="Data Set Details" styleClass="east_panel_header" >
        <h:form id="tblbrowser">  
            <p:dataTable id="dataTable" emptyMessage="No data sets found." style="width: 100%" var="datlis" resizableColumns="true" value="#{databrowser.selectedDataModel}" widgetVar="dataTable" selection="#{databrowser.selectedData}" selectionMode="single" >  

            <p:ajax event="rowSelect" update=":usercomments:commentsTable, :tblbrowser:dataTable" />

            <f:facet name="header" >
                <p:outputPanel>  
                <h:outputText value="Search all fields " />  
                <p:inputText id="globalFilter" onkeyup="dataTable.filter()"/>  
                </p:outputPanel>  
            </f:facet>  

            <p:column id="owner" filterBy="#{datlis.uname}" headerText="Added By" filterMatchMode="contains" >  
                <h:outputText value="#{datlis.uname}" />  
            </p:column>  

            <p:column id="name" filterBy="#{datlis.name}" headerText="Name" >  
                <h:outputText value="#{datlis.name}" />  
            </p:column>  

            <p:column id="description" filterBy="#{datlis.description}" headerText="Description" filterMatchMode="endsWith" >  
                <h:outputText value="#{datlis.description}" />  
            </p:column> 

            <p:column id="datatype" filterBy="#{datlis.data_type}" headerText="Data Type"  
                    filterOptions="#{databrowser.dataTypeOptions}" filterMatchMode="exact" >  
                <h:outputText value="#{datlis.data_type}" />  
            </p:column>  

            <p:column id="quality" filterBy="#{datlis.quality}" headerText="Source Type"  
                    filterOptions="#{databrowser.qualityOptions}" filterMatchMode="exact" >  
                <h:outputText value="#{datlis.quality}" />  
            </p:column>  

            <p:column id="added" headerText="Date Added" filterMatchMode="endsWith" >  
                <h:outputText value="#{datlis.added}" />  
            </p:column>  

            <p:column headerText="Metadata" style="width:40px" >  
                <p:commandButton id="selectButton" rendered="#{datlis.has_metadata}" icon="ui-icon-circle-arrow-s" title="View" ajax="false" >  
                    <f:param name="filepath" value="#{datlis.filepath}" />   
                    <p:fileDownload value="#{filedownloader.mfile}" /> 
                </p:commandButton>
            </p:column>

            <p:column headerText="Data File(s)" style="width:90px" >  
                <p:commandButton id="selectButton2" rendered="#{datlis.has_datafiles}" icon="ui-icon-circle-arrow-s" title="View" ajax="false" >  
                    <f:param name="datafiles" value="#{datlis.datafiles}" />   
                    <p:fileDownload value="#{filedownloader2.dfile}" /> 
                </p:commandButton>
                <h:outputText value=" " />  
                <h:outputText value="#{datlis.zipsize}" />  
            </p:column>   

            </p:dataTable>  
        </h:form>  
    </p:layoutUnit>

您缺少rowKey属性,该属性应该是每一行的唯一标识符。

例如,如果您的selectedData对象具有唯一的字段id ,则dataTable组件应如下所示:

<p:dataTable id="dataTable" rowKey=#{datlis.id}
             value="#{databrowser.selectedDataModel}" var="datlis"
             selection="#{databrowser.selectedData}" selectionMode="single" >

无需更新p:ajax的同一表即可查看选择,因此您可以从更新目标中删除:tblbrowser:dataTable ,而仅具有:

<p:ajax event="rowSelect" update=":usercomments:commentsTable" />

暂无
暂无

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

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