Our pure JavaScript Scheduler component


Post by Craig Milne »

Hi Bryntum team

I am wanting to load in calendar data to Scheduler Pro like I load in all other data, via a PHP script.
For example, this is how assignment data are handled:

assignmentStore : 
	{
        createUrl : 'cmsincludes/libs/bryntum_dev/php/assignmentscreate.php',
        readUrl   : 'cmsincludes/libs/bryntum_dev/php/assignmentsread.php',
        updateUrl : 'cmsincludes/libs/bryntum_dev/php/assignmentsupdate.php',
        deleteUrl : 'cmsincludes/libs/bryntum_dev/php/assignmentsdelete.php',
		autoLoad: true,
		autoCommit: true,
		writeAllFields: true
    },

I can get the calendar data loading inline OK, but can't get it to read from a file.

Loading all data (events, resources, calendar etc.) from one file (e.g. 'loadUrl') is not suitable for my purposes, I would like to keep the individual data handling files like in my example above.

If possible could you please suggest a way I could load in calendar data from an external URL, thanks.


Post by tasnim »

Hi,

You can load it like the way you're loading assignments
https://bryntum.com/products/schedulerpro/docs/api/SchedulerPro/model/ProjectModel#config-calendarManagerStore

calendarManagerStore : {
	readUrl : 'yourReadUrl',
	createUrl : '...',
	updateUrl : '....'
	....
}

I can get the calendar data loading inline OK, but can't get it to read from a file.

Though, I'm not sure what you mean by that!

Best regards,
Tasnim


Post by Craig Milne »

Hi Tasnim

OK great, seems pretty obvious now that you have pointed it out. Thanks!


Post by Craig Milne »

Hi there

I'm still having trouble loading in a custom calendar. I'd appreciate it if you could have a look at this and offer any suggestions.

My Scheduler declaration

const scheduler = new SchedulerPro
({		
	calendarManagerStore : 
	{
		readUrl : 'cmsincludes/libs/bryntum_dev/php/calendarread.php',
		autoLoad : true
	},
	project : {			
		// set default project calendar
       calendar             : 'test',		
	},
	ref : 'scheduler',

calendarread.php produces the following JSON

{"calendars":{"rows":{"id":"test","name":"Weekends","intervals":{"recurrentStartDate":"on Sat at 0:00","recurrentEndDate":"on Mon at 0:00","isWorking":false}}}}

but the CalendarManagerStore remains empty, it doesn't load in my 'test' calendar.
I've tried all kinds of variations but had no luck getting it to work.

If I use this Scheduler declaration it works fine, but then I can't make the calendar data dynamic:

const scheduler = new SchedulerPro
({		
	project : {			
       calendar : 'test',
	   calendarsData : [
            {
                id        : 'test',
                name      : 'Weekends',
                intervals : [
					{
                        recurrentStartDate : 'on Sat at 0:00',
                        recurrentEndDate   : 'on Mon at 0:00',
                        isWorking          : false
                    }
                ]
            }
        ]
	},
	ref : 'scheduler',

Thanks....


Post by alex.l »

Hi,

Try to use store data format, since you use store level data and not ProjectModel, that you copied data format from

{
    "success" : true,
    "total"   : 50000,
    "data"    : [{
            "id":"test","name":"Weekends","intervals": ......
        }]
}

All the best,
Alex


Post by Craig Milne »

Hi Alex

That worked for me, thank you so much! Now I can customise the non-working intervals as I need to. This is the JSON now produced by calendarread.php, which is successfully loaded in as the project calendar:

{
  "success": true,
  "data": [
    {
      "id": "test",
      "name": "Test",
      "intervals": [
        {
          "recurrentStartDate": "on Sat at 0:00",
          "recurrentEndDate": "on Mon at 0:00",
          "isWorking": "false"
        }
      ]
    }
  ]
}

Post by marcio »

Hey Craig Milne,

Glad that is all working now and thanks for sharing your implementation here, for sure it'll help others in the forums! :)

Best regards,
Márcio


Post by Craig Milne »

Hi Marcio

No problem, happy to add to these forums which are an excellent resource....thanks again.


Post Reply