簡體   English   中英

Primefaces Schedule-如何格式化列標題

[英]Primefaces Schedule - how to format column headers

我正在嘗試使用p:schedule ,但是列標題顯示的格式如下: EEE MM/dd ,我確實需要切換到EEE dd/MM

在研究primefaces論壇和google項目時,我遇到了這個問題(以及其他幾個主題): http : //code.google.com/p/primefaces/issues/detail? id=2546

似乎解決了這個問題,但是對於如何使用它來解決問題我一無所知。

我不確定這個問題是否是重復的(因為問題已經困擾了兩年了),但是搜索SO並沒有帶來任何成功。

那么,如何更改列標題的格式?

我將展示示例導入到我的項目中,到目前為止,我的日程表事件的配置是:

<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">

使用Primefaces 3.3.1

一個非常粗糙的解決方案,我通過劫持時間表頁面的輸出,更改時間表調用的javascript代碼以將格式放入其中來修復了這些標頭:

我使用了傑里米·斯坦(Jeremy Stein)編寫的類(單擊以提問) (是的,在HTML輸出上使用正則表達式,在bash上使用),並放置了一個篩選器,以監聽計划的特定頁面的輸出。

我使用以下模式和替換字符串:

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

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

通過在輸出中插入columnFormat屬性,它開始正確渲染標題。

我很樂意看到另一種解決Primefaces不願實現此功能的方法。

我解決了從primefaces(scheduler.js)入侵JavaScript的問題。 只需在您的頁面中添加以下代碼即可編輯日期格式:

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;
     }
};

}

我通過修改“ columnFormat”屬性解決了這個問題。

columnFormat="month:'ddd', week:'dd/MM', day:'dd/MM/yyyy'}, titleFormat: {day: 'dddd, dd \'de\' MMMM \'de\' yyyy'"

使用primefaces的最新版本,現在可以解決此問題。 您只需在p:schedule標記中添加columnFormat =“ ddd D / M”,如下所示:

<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">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM