Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

jsf - setting default value in primefaces datatable Filter

I am using primefaces v3.5.On the datatable I am using filter on one column. How can I set a default value to the filter while loading the page Itself.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use the filterValue property of the column tag in primefaces, something like

<p:datatable ... widgetVar="dataTableWidgetVar">
<p:column  ...    filterValue="#{BackingBean.defaultValue}">

Then, create a simple function call in javascript for triggering the filter, when the page is ready (the widget vars are created via jQuery in PF):

<script  type="text/javascript" target="body">
$j = jQuery;
$j(document).ready( function() {
dataTableWidgetVar.filter();   
});
</script>    

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...