Jump to content

Background Color of clicked day in UniCalendarPanel1 / month-view


erich.wanker

Recommended Posts

1 hour ago, Freeman35 said:

On this thread, you can see, selected date 31 october 2018, in uniCalendar, on left side. How to show this selected day in uniCalenderPanel ?

Maybe something like this?

procedure SetBG(ACalendarPanel: TUniCalendarPanel; ADate: TDateTime);

procedure TMainForm.SetBG(ACalendarPanel: TUniCalendarPanel; ADate: TDateTime);
begin
  with ACalendarPanel do
  begin
    JSInterface.JSCode(#1'.getEl().select(''.x-calendar-weeks-cell'').elements.forEach(function(el){el.style["background-color"]=""});');
    JSInterface.JSAssign('selDate', [FormatDateTime('YYYY-mm-dd', ADate)]);
    JSInterface.JSCode('me='#1'.getEl().select(''.x-calendar-weeks-cell[data-date="''+'#1'.selDate+''"]'').elements[0]; if(me){me.style["background-color"]="green"};');
  end
end;
procedure TMainForm.UniCalendar1Click(Sender: TObject);
begin
  UniCalendarPanel1.StartDate := UniCalendar1.Date;
  SetBG(UniCalendarPanel1, UniCalendarPanel1.StartDate);
end;
procedure TMainForm.UniCalendarPanel1DateChange(Sender: TUniCalendarPanel;
  StartDate, ViewStart, ViewEnd: TDateTime);
begin
  UniCalendar1.Date := UniCalendarPanel1.StartDate;
  SetBG(UniCalendarPanel1, UniCalendarPanel1.StartDate);
end;
procedure TMainForm.UniCalendarPanel1ViewChange(Sender: TUniCalendarPanel;
  CurrentView: TUniCalendarViewType);
begin
  if CurrentView = cvMonth then
    SetBG(UniCalendarPanel1, UniCalendarPanel1.StartDate);
end;

...

Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...