0

I am trying to use a p:schedule, but the column headers are showing the format like: EEE MM/dd and I really need to switch to EEE dd/MM.

researching the primefaces forums and google project, i ran into this (and several other threads): http://code.google.com/p/primefaces/issues/detail?id=2546

that seems to address the issue, but I am clueless as to how to use it to solve the issue.

I am unsure as to wheter this question is a duplicate (as the issue has been lingering around for a couple years now) but searching the SO did not come with any hits.

So, how can I change the format of the column headers?

I imported the showcase example into my project, so far the config of my schedule event is:

<p:schedule value="#{scheduleController.eventModel}"
widgetVar="myschedule" view="agendaWeek"     allDaySlot="false"
slotMinutes="15" firstHour="7" showWeekends="FALSE"
leftHeaderTemplate="prev,next" rightHeaderTemplate=""
minTime="7am" maxTime="21pm" timeFormat="dd/MM hh:mm"
axisFormat="HH">

using primefaces 3.3.1

Mindwin Remember Monica
  • 1,469
  • 2
  • 20
  • 35
  • one way out is to hard edit the shedule.js file in the primefaces package, but then you break the JAR. http://forum.primefaces.org/viewtopic.php?f=3&t=25552 - not acceptable, but the primefaces guys don't seem to care. – Mindwin Remember Monica Oct 30 '12 at 14:24

4 Answers4

0

A very crude solution, I fixed these headers by hijacking the output of the schedule page, changing the javascript code for the schedule call in order to put the format in it:

I used the classes written by Jeremy Stein (click to go to question) (yeah, regex on HTML output, bash on) and placed a filter listening on the output of the specific page with the schedule.

I used the following Pattern and Replace String:

Pattern. compile("timeFormat:(.*?), behaviors");

replaceString= "timeFormat: $1, columnFormat : { month : 'ddd' , week : 'ddd d/M' , day : 'dddd d/M' }, behaviors"

by inserting the columnFormat property in the output, it started rendering the headers right.

I would love to see another way to get around Primefaces reluctance in implementing this feature.

Community
  • 1
  • 1
Mindwin Remember Monica
  • 1,469
  • 2
  • 20
  • 35
0

I solved it hacking the javascript from primefaces (scheduler.js). Just add this code in your page to edit the date formats:

if (PrimeFaces.widget.Schedule != undefined) {
PrimeFaces.widget.Schedule.prototype.init = function() {
     this.cfg.titleFormat = {
            month: 'MMMM yyyy',
            week: "De d MMM [ yyyy]{ 'à' d [ MMM] 'de' yyyy}",
            day: 'dddd, d MMM , yyyy'
     };          
     this.cfg.columnFormat = {
            month: 'ddd',
            week: 'ddd d/M',
            day: 'dddd M/d'
     };
     if(this.jq.is(':visible')) {
        this.jqc.fullCalendar(this.cfg);
        return true;
     }  else {
        return false;
     }
};

}

viniciusjssouza
  • 1,235
  • 14
  • 28
0

I solved this problem by hacking the "columnFormat" attribute.

columnFormat="month:'ddd', week:'dd/MM', day:'dd/MM/yyyy'}, titleFormat: {day: 'dddd, dd \'de\' MMMM \'de\' yyyy'"
Nathan Tuggy
  • 2,237
  • 27
  • 30
  • 38
rsiqueira
  • 21
  • 3
0

With last versions of primefaces, this is now solved. You just have to add columnFormat="ddd D/M" in the p:schedule tag, like below:

<p:schedule value="#{scheduleController.eventModel}"
widgetVar="myschedule" view="agendaWeek"     allDaySlot="false"
slotMinutes="15" firstHour="7" showWeekends="FALSE"
leftHeaderTemplate="prev,next" rightHeaderTemplate=""
minTime="7am" maxTime="21pm" timeFormat="dd/MM hh:mm"
axisFormat="HH" columnFormat="ddd D/M">
eric A
  • 786
  • 6
  • 6