3
votes

Is there a solution to set a "DefaultValue" for the "filterBy" Component ?? I mean more precisely ... How can I set the value of the component shown in the picture ?

http://www.pictureupload.de/originals/pictures/111012170732_primefaces.png

Or how can I set a defaultValue for the option "filtering" in the p:column?!

            <p:column id="artikelVerkaufDatum" headerText="Datum" filterBy="#{sales.dateForFilter}"
                filterMatchMode="startsWith">
                <h:outputText id="date" value="#{sales.datum}">
                    <f:convertDateTime type="date" pattern="dd.MM.yyyy HH:MM:ss" />
                </h:outputText>
            </p:column>

Ok ... another question ... My FireBug says that the component exists with ... but i cannot access it with for example: something like FacesContext.getCurrentInstance().getViewRoot().findComponent ... I always get a NullpointerException :(

<th id="artikelVerkauf:datatable:artikelVerkaufDatum" class="ui-state-default ui-filter-column" role="columnheader">
<div class="ui-dt-c">
<span>Datum</span>
<input id="artikelVerkauf:datatable:artikelVerkaufDatum_filter" class="ui-column-filter ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all" autocomplete="off" value="" name="artikelVerkauf:datatable:artikelVerkaufDatum_filter" role="textbox" aria-disabled="false" aria-readonly="false" aria-multiline="false">
</div>
</th>

If anybody has any idea ... please let me know ! every help is welcomed :) Regards Sway

1
in order to get better/more accurate answers it would be good to separate your questions. If you ask several questions in one question you risk having answers that are both correct and wrong at the same time. - Akos K
For your first question look here - kolossus

1 Answers

2
votes

This is a solution I used once (PF 3.5):

  • First set widgetVar="tableWidget" for the datatable.
  • Assign a filterStyleClass="my-column-filter" for the p:column that is filtered
  • Then insert the following JavaScript which will be executed after the DOM is ready:

    $( document ).ready(function() { $('.my-column-filter').val('default'); tableWidget.filter(); });

Good luck!