How to show water mark in filter in primefaces?

后端 未结 3 486
借酒劲吻你
借酒劲吻你 2021-01-28 03:25

I have filters for columns.

Here i want to show water mark in filter (As Shown in figure in red circle)

I am using prime faces 3.4

I have tred this

相关标签:
3条回答
  • 2021-01-28 03:53

    There is an attribute forElement of p:watermark for that. The specifications state that forElement should contain jquery selector of the html input component. But according to these threads here and here, the forElement should strictly be only the client ID of the html input component.

    So you can do following:

    <p:dataTable id="battingStyleTable" ... ... ..>
    
        <p:column id="myColumn"
            filterBy="#{battingStyle.battingStyleString}" 
            filterMatchMode="contains">
    
            <f:facet name="header">Name</f:facet>
            <h:outputText value="#{battingStyle.battingStyleString}" />
    
            <p:watermark value="Watermark text"
                forElement='battingStyleTable:myColumn_filter'></p:watermark>
            <!-- Please note that the prependId of my form is false, and id of the datatable is battingStyleTable and id of the column is myColumn. Thats why the id of the textfield of the filter will be battingStyleTable:myColumn_filter. Please change it accordingly. If you can't do prependId="false" to your form then you must include form id in the start also, like myFormId:myDatatableId:myColumnId_filter -->
        </p:column>
        ...............
        ..........
        ................
    </p:dataTable>
    
    0 讨论(0)
  • 2021-01-28 03:57

    Try to use this syntax to address the filter field. Worked for me with Primefaces 6.1.

    <h:form id="f_myForm">
      <p:dataTable id="dt_myTable">
        <p:column id="col_myCol>
          <h:outputText id="ot_myText" />
          <p:watermark for="@(#f_myForm\\:dt_myTable\\:col_myCol\\:filter)" value="MyPlaceholder" />
        </p:column>
      </p:dataTable>
    </h:form>
    
    0 讨论(0)
  • 2021-01-28 03:58

    Finally got solution.

    <h:form id="parametersListForm">      
    
        <p:dataTable id="parameteresList" value="#{parameterController.lstParameter}"
                     var="parameters" styleClass="tnt-main-table"> 
    
        <p:column id="columnRefType" filterBy="#{parameters.beRefType}" >
            <h:outputText value="#{parameters.beRefType}" />
            <p:watermark forElement="parametersListForm:parameteresList:columnRefType:filter"
                         value="#{msgs['parameters.beRefType.label']}"/>  
            </p:column>
         </p:dataTable>              
    </h:form>
    

    Hope it helps to some one :)

    0 讨论(0)
提交回复
热议问题