Custom calendar issue


From the images above, you can see the design logic. My issue is when I select the week, I want the current week that includes the current day to be the one showing not the first week

We’ll need more information on how you set this calendar up on your editor.
Right now all we can really say is that there are many viable ways to achieve this :slight_smile:

I used JavaScript expression. I was thinking if there’s a conditional I can use. For the month, I used current date extract month. And it worked. So I’m sure there should be a way I can counter it to achieve the the same for the “week” also

You could use a conditional that changes the javascript code and changes RG’s datasource to this:

function getDatesForWeek(offset) {
    var today = new Date();
    
    var startOfWeek = today.getDate() - today.getDay();
    var currentWeekStartDate = new Date(today.setDate(startOfWeek));
    
    var targetWeekStartDate = new Date(currentWeekStartDate.setDate(currentWeekStartDate.getDate() + (offset * 7)));
    
    var days = [];
    for (var i = 0; i < 7; i++) {
        var day = new Date(targetWeekStartDate);
        day.setDate(day.getDate() + i);
        days.push(day);
    }

    return days;
}

You could have also gone the lowcode route and used the the Bubble expression editor by using the :change day operator and the :plus days:current cell index operator on a RG with 7 columns and 1 row.

I’ll try both and let you know. But can you work me through the low code method if you don’t mind

This topic was automatically closed after 70 days. New replies are no longer allowed.