【问题标题】:Hide the Event time of p:schedule in primefaces在primefaces中隐藏p:schedule的事件时间
【发布时间】:2017-06-16 16:52:37
【问题描述】:

我正在使用 primefaces <p:schedule>,我想在某些情况下隐藏事件时间。

我使用的条件是我传递给DefaultScheduleEvent 的对象的一个​​属性,它也有事件标题。

我找到的解决方案是将display:none; 用于css 类.fc-event-time,它将隐藏日程中的所有事件时间。

所以我想做的是当我创建一个新的DefaultScheduleEvent 时:

defaultScheduleEvent = new DefaultScheduleEvent(item.getFormule().getLibelle(), startPlanningDate, endPlanningDate, "formuleColor" + item.getFormuleCremation().getId());

它将调用item.isDispo(),如果为真则隐藏事件时间,否则显示。

我该怎么做?

【问题讨论】:

  • 你试过用 item.isDispo() 渲染吗?
  • @BillyHope 我在哪里可以使用渲染?在 xhtml 代码中,您只调用 p:schedule 元素

标签: javascript jsf primefaces


【解决方案1】:

您可以通过两种方式做到这一点:

  1. 扩展fc-timecss

css

.fc-time, .hide-time {
    display:none;
}

String hideCss = "";

if (item.isDispo()) {
    hideCss = "hide-time";
}

defaultScheduleEvent = new DefaultScheduleEvent(item.getFormule().getLibelle(), startPlanningDate, endPlanningDate, "formuleColor" + item.getFormuleCremation().getId() + " " + hideCss);
  1. allDay 标志设置为真

defaultScheduleEvent = new DefaultScheduleEvent(item.getFormule().getLibelle(), startPlanningDate, endPlanningDate, item.isDispo());

第二种方式不适用于您的情况,因为您将 "formuleColor" + item.getFormuleCremation().getId() 添加为自定义 css

希望这会有所帮助。

【讨论】:

  • 第一个解决方案不起作用,因为当您添加hide-time 类时,它将在日程表中隐藏整个事件,并且应该隐藏的 div 是事件元素的子元素。
  • div fc-content 有两个 span 作为子级,分别有 fc-timefc-title 类。您可以在浏览器的开发者工具中检查这一点(按 F12)。我的解决方案只在fc-time 中添加了隐藏时间。你试过吗?不过,它在我的应用程序中运行良好。
  • 感谢帮助,我用你的方法解决了,但我用的是.fc-time, .hide-time {display:none;}而不是:.hide-time .fc-time {display:none;}
  • 很高兴听到您解决了问题。如果有帮助,请将答案标记为已接受。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-12
  • 2012-06-09
  • 1970-01-01
相关资源
最近更新 更多