search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Displaying Group Availability

Asked by VitseA
10 months ago.

Hi,

I'm having trouble using displaying group availability.

The last one day of my event is not taken.

i'm using this parameter dp.eventEndSpec = "Date"; and not "Datetime" ( my choice)

How can I modify this to resolve my issue ?

args.cell.start => 2022-01-23T00:00:00
args.cell.end => 2022-01-27T00:00:00

i was trying to convert like this args.cell.start.toString("M/d/yyyy") but after it's compare two string and it's based on object

var used = children.filter(function(row) {
return !!row.events.forRange(args.cell.start, args.cell.end).length;
}).length;

Thanks for advance

Comment posted by Dan Letecky [DayPilot]
10 months ago.

The group availability project (https://code.daypilot.org/97538/javascript-scheduler-displaying-group-availability) seems to work as expected if I add eventEndSpec: "Date" to the config. That is, the group totals correspond to the events displayed.

So the problem might be somewhere else. If you want to modify the datetime values (DayPilot.Date objects) you can use the class methods (https://api.daypilot.org/daypilot-date-methods/) to do custom calculations, e.g.

const nextDay = args.cell.start.addDays(1);

Let me know if it doesn't help.

Comment posted by VitseA
10 months ago.

Thanks you for your time but it's doesn't solve it.

I don't know why args.cell.end take 2022-01-27 and not 2022-01-28T like my database

Have you got any idea ?

Comment posted by Dan Letecky [DayPilot]
10 months ago.

Maybe you are checking an incorrect property. The args.cell property holds information about the background cell. For the last cell in the screenshot (Saturday January 29, 2022) the values should be:

args.cell.start => 2022-01-29T00:00:00
args.cell.end => 2022-01-30T00:00:00

Comment posted by VitseA
10 months ago.

My context menu return args.source.end => 2022-01-30T00:00:00

Comment posted by VitseA
10 months ago.

this is my code

dp.onBeforeCellRender = function(args) {

            // Highlighting today
            if (args.cell.start <= DayPilot.Date.today() && DayPilot.Date.today() < args.cell.end) {
                args.cell.backColor = "#ffcccc";
            }

            // Disabled Cells
            var row = dp.rows.find(args.cell.resource);
            var display = row.data.display
            var boolValue = display.toLowerCase() == 'true' ? true : false;

            if (boolValue === false) {
                args.cell.disabled = true;
                args.cell.backColor = "#ccc";
            }

            // Displaying Group Availability
            if (args.cell.isParent) {

                var children = dp.rows.find(args.cell.resource).children().filter(function(row) {
                    return JSON.parse(row.data.display); // disable Availability for display = false column
                });

                var total = children.length;

                var used = children.filter(function(row) {
                    return !!row.events.forRange(args.cell.start, args.cell.end).length;
                }).length;

                var available = total - used;

                var w = dp.cellWidth / total;

                args.cell.areas = [];

                args.cell.areas.push({
                    html: "" + available,
                    style: "text-align: center; font-size: 12px; font-weight: bold",
                    top: 4,
                    left: 0,
                    right: 0
                });

                args.cell.backColor = "#d9ead3";

                if (available === 0) {
                    args.cell.backColor = "#f9cb9c";
                }

                DayPilot.list.for(total).forEach(function(item, i) {
                    var color = "#b6d7a8";
                    if (i < used) {
                        color = "#6aa84f";
                    }
                    if (available === 0) {
                        color = "#e69138";
                    }
                    args.cell.areas.push({
                        bottom: 0,
                        height: 10,
                        left: i * w,
                        width: w - 1,
                        backColor: color
                    });
                })
            }
  }
Comment posted by Dan Letecky [DayPilot]
10 months ago.

This seems to work fine - I'm testing it with the sample project from https://code.daypilot.org/97538/javascript-scheduler-displaying-group-availability.

What version of DayPilot do you use? If it's an older version, could you please give it a try with the latest release?

Comment posted by VitseA
10 months ago.

i'm using

DayPilot Pro for JavaScript 2020.1.4174

Answer posted by Dan Letecky [DayPilot]
10 months ago.

This issue has been fixed in version 2020.3.4547:
https://javascript.daypilot.org/daypilot-pro-for-javascript-2020-3-4547/

I recommend switching to the latest version though - which is now 2022.1.5188.

Comment posted by VitseA
10 months ago.

it doesn't change anything...

Comment posted by VitseA
10 months ago.

https://api.daypilot.org/daypilot-scheduler-eventendspec/

When i disable this
dp.eventEndSpec = "Date";

But i need it

Comment posted by Dan Letecky [DayPilot]
10 months ago.

The latest version works with eventEndSpec: "Date" as well. You can verify it in the sample project available in the tutorial (https://code.daypilot.org/97538/javascript-scheduler-displaying-group-availability).

I recommend checking that the library is properly updated and loaded (make sure it's not using an old cached version).

If you are able to reproduce the problem using the sample project please let me know. However, in my tests it works fine.

Answer posted by VitseA
10 months ago.

(make sure it's not using an old cached version) => solved my issue

Now it's worked

Answer posted by VitseA
9 months ago.

i have an issue regarding this solved !

I have changing daypilot-all.min.js but now it'm back to trial version ...

How can i get back my license ?

Answer posted by VitseA
9 months ago.

i'm sorry i have download the last version Pro

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.