4
Like remover os dias
of the primefaces?
I tried the configuration below, but the days are displayed when the component is redeveloped.
<p:calendar id="dataTeste" pattern="MM/yyyy" />
Here’s the rendered component image:
4
Like remover os dias
of the primefaces?
I tried the configuration below, but the days are displayed when the component is redeveloped.
<p:calendar id="dataTeste" pattern="MM/yyyy" />
Here’s the rendered component image:
6
The Primefaces component does not natively support this.
Options would be:
However, unless the visual issue is something much needed, perhaps a simpler solution is recommended. Simply use a combo with the possible date range, each item containing mês/ano
. Or even two combos, one with month and one with year.
Particularly, I see no advantage as a user in having to press arrows to advance or back the month as it takes more work if I want to go to a date further away.
4
Old topic, but I’ll leave an alternative solution that uses javascript and CSS to solve this problem...
OBS: Tested in Primefaces 5.2...
function setData(){
ano = $("#data .ui-datepicker-year").val();
mes = $("#data .ui-datepicker-month").val();
$('#data_input').val(('0' + (++mes)).slice(-2)+'/'+ano);
}
$( "#data .ui-datepicker-month" ).change(function() {
setData();
});
$( "#daa .ui-datepicker-year" ).change(function() {
setData();
});
.ui-datepicker-inline .ui-datepicker-calendar{
display: none;
}
<p:calendar id="data" value="#{bean.data}" mode="inline" navigator="true" pattern="MM/yyyy"/>
Upshot:
Browser other questions tagged primefaces
You are not signed in. Login or sign up in order to post.
Interesting alternative! Easier than creating the combos separately. Just take care of 3 things: (1) in practice you should not overwrite all calendars as in the example; (2) test the code at each Primefaces upgrade to check for changes that break the code; (3) beware of manipulating the object
Date
because it will come with some "random" day, so if the back end make some kind of manipulation on that date may incur unexpected results.– utluiz