Our pure JavaScript Scheduler component


Post by tristan »

Hello,

I'd like to have 2 schedulers that display the same events but with different resources.

I tried to make both scheduler point to the same event and dependy store :
eventStore,
dependencyStore,

But with two different stores for resources and assignments:
resourceStore1
assignmentStore1

resourceStore2
assignmentStore2

But I get errors when modifying assignmentStore2 :

Can you help me?

Thanks for your help.

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '0')
    at get isPersistable (AssignmentModelMixin.js:275:5)
    at StoreCRUD.js:22:5
    at Array.filter (<anonymous>)
    at StoreBag.add (StoreCRUD.js:22:5)
    at AssignmentStore2.onDataChange (Store.js:822:17)
    at _Collection.trigger (Events.js:1372:46)
    at _Collection.splice (Collection.js:729:17)
    at _Collection.add (Collection.js:443:5)
    at AssignmentStore2.add (StoreCRUD.js:446:5)
    at AssignmentStore2.add (StoreStm.js:84:19)
Revision.js:8 Uncaught (in promise) Error: Unknown identifier ModelClass-1.$.endDateDirection
    at throwUnknownIdentifier (Revision.js:8:9)
    at EngineTransaction.addEdge (Transaction.js:563:5)
    at EngineTransaction.onReadIdentifier (Transaction.js:624:38)
    at EngineTransaction.calculateTransitionsStackGen (Transaction.js:770:36)
    at calculateTransitionsStackGen.next (<anonymous>)
    at EngineTransaction.calculateTransitions (Transaction.js:666:5)
    at calculateTransitions.next (<anonymous>)
    at runGeneratorAsyncWithEffect (Quark.js:8:23)
    at Transaction.js:528:16

Post by tasnim »

Hi,

Is it possible to see a glimpse of your code how are you implementing that?


Post by tristan »

In this example, only the resourceStore is the same between the 2 schedulers.
Initialization of the 2 scheduler :

// Définition des champs personnalisés pour les événements
	const eventFields = [
		{ name: 'description', type: 'string' }
	];




// création du resource store
window.MonresourceStore = new ResourceStore({
	autoCommit: true,
});

// création du assignement store
window.MonassignmentStore = new AssignmentStore({
	autoCommit: true,
});


// création de l'event store
window.MoneventStore = new EventStore({
	autoCommit: true,
	fields: eventFields,
});



PresetManager.registerPreset('FullDayAndTime', {
	name              : 'FullDayAndTime (custom)',
	tickWidth         : 10,
	rowHeight         : 32,
	displayDateFormat : 'HH:mm',
	shiftIncrement    : 1,
	shiftUnit         : 'day',
	timeResolution    : {
		unit      : 'minute',
		increment : 30
	},
	defaultSpan     : 24,
	mainHeaderLevel : 1,
	headers         : [
		{
			unit       : 'day',
			increment  : 1,
			dateFormat : 'dddd Do MMMM YYYY'
		},
		{
			unit       : 'hour',
			increment  : 1,
			dateFormat : 'H'
		}
	]
});    

//-----------------------------------------------------------Fin viewPreset-------------------------------------




//--------------------------------------------------------------------------------------------------- création du scheduler
window.Monscheduler = new SchedulerPro({

	appendTo: 'cible_scheduler',
	startDate: new Date(),
	endDate: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000), // 7 days
	eventStyle: 'colored',
	
	minHeight : '10em',
	flex      : '1 1 50%',

	
	 
	viewPreset: 'FullDayAndTime',  
	

	eventStore: MoneventStore,
	resourceStore: MonresourceStore,
	assignmentStore: MonassignmentStore,
	
	
	
   
	//colonnes des ressources
	columns: [
		{
			text: 'Name',
			field: 'name',
			width: 150,
		  editor: null //empeche la modification
		},
		{
			text: 'Prénom',
			field: 'prenom',
			width: 150,
		  editor: null
		}
	],

});



// création du resource store
window.MonresourceStore2 = new ResourceStore({
	autoCommit: true,
});



// création de l'event store
window.MoneventStore2 = new EventStore({
	autoCommit: true,
	fields: eventFields,
});

// création du assignement store
	window.MonassignmentStore2 = new AssignmentStore({
		autoCommit: true,
	});
	

//--------------------------------------------------------------------------------------------------- création du scheduler
window.Monscheduler2 = new SchedulerPro({

	appendTo: 'cible_scheduler2',
	startDate: new Date(),
	endDate: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000), // 7 days
	eventStyle: 'colored',
	
	minHeight : '10em',
	flex      : '1 1 50%',

	
	
	viewPreset: 'FullDayAndTime',  
	
	eventStore: MoneventStore2,
	resourceStore: MonresourceStore,
	assignmentStore: MonassignmentStore2,
	
	
   
	//colonnes des ressources
	columns: [
		{
			text: 'Name',
			field: 'name',
			width: 150,
		  editor: null //empeche la modification
		},
		{
			text: 'Prénom',
			field: 'prenom',
			width: 150,
		  editor: null
		}
	],
   
});

Add resource :

	var NewRessource = {};
	
NewRessource.id = 1;
NewRessource.name = 'name';
NewRessource.prenom = 'prenom';
MonresourceStore.addAsync([NewRessource]);

NewRessource.id = 2;
NewRessource.name = 'name2';
NewRessource.prenom = 'prenom2';
MonresourceStore.addAsync([NewRessource]);

Add an event :

	var NewEvent;
	NewEvent.id         = 1;
	NewEvent.name = 'event 1';
	NewEvent.startDate  = new Date();
	NewEvent.endDate    = new Date();
	eventStore.addAsync([NewEvent]);
	
NewEvent.id         = 2;
NewEvent.name = 'event 2';
NewEvent.startDate  = new Date();
NewEvent.endDate    = new Date();

eventStore.addAsync([NewEvent]);

add assignments :

	JSON_Assignment.id = 1;
	JSON_Assignment.eventId = 1;
	JSON_Assignment.resourceId = 1;
	JSON_Assignment.addAsync(JSON_Assignment);
	
JSON_Assignment.id = 2;
JSON_Assignment.eventId = 2;
JSON_Assignment.resourceId = 1;
MonassignmentStore.addAsync(JSON_Assignment);

As you see here, i juste have the same resourceStore and my event aren't show in my scheduler 1.
But they are shown if in the seconde scheduler i link the second resourcestore :

eventStore: MoneventStore2,
resourceStore: MonresourceStore2,
assignmentStore: MonassignmentStore2,

Post by alex.l »

Hi,

You need to chain resourceStore to your second Scheduler instance. Please see demo here https://bryntum.com/products/scheduler/examples/shared-crudmanager/

https://bryntum.com/products/schedulerpro/docs/api/Scheduler/data/ResourceStore#function-chain

That should help to avoid such problem.

All the best,
Alex


Post by tristan »

Hi and thx for reply.

I've try this for my second scheduler :


// création du resource store
window.MonresourceStore2 = MonresourceStore.chain();

// création de l'event store
window.MoneventStore2 = MoneventStore.chain();

// création du assignement store
window.MonassignmentStore2 = MonassignmentStore.chain();


//--------------------------------------------------------------------------------------------------- création du scheduler
	window.Monscheduler2 = new SchedulerPro({

	appendTo: 'cible_scheduler2',
	startDate: new Date(),
	endDate: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000), // 7 days
	eventStyle: 'colored',
	
	minHeight : '10em',
	flex      : '1 1 50%',

	
	
	viewPreset: 'FullDayAndTime',  
	
	eventStore: MoneventStore2,
	resourceStore: MonresourceStore2,
	assignmentStore: MonassignmentStore2,
	
	
   
	//colonnes des ressources
	columns: [
		{
			text: 'Name',
			field: 'name',
			width: 150,
		  editor: null //empeche la modification
		},
		{
			text: 'Prénom',
			field: 'prenom',
			width: 150,
		  editor: null
		}
	],
   
});

but i've this error, directly when i try to add resources to my first scheduler :

Uncaught (in promise) Error: Unknown identifier ProjectModel2.$.effectiveCalendar
    at throwUnknownIdentifier (Revision.js:8:9)
    at EngineTransaction.addEdge (Transaction.js:563:5)
    at EngineTransaction.onReadIdentifier (Transaction.js:624:38)
    at EngineTransaction.calculateTransitionsStackGen (Transaction.js:770:36)
    at calculateTransitionsStackGen.next (<anonymous>)
    at EngineTransaction.calculateTransitions (Transaction.js:666:5)
    at calculateTransitions.next (<anonymous>)
    at runGeneratorAsyncWithEffect (Quark.js:6:22)
    at async EngineReplica2.doCommitAsync (Graph.js:379:31)
    at async ProjectModel2.internalDelayCalculation (SchedulerBasicProjectMixin.js:414:9)

Post by alex.l »

Hi,

Could you please attach runnable code to debug that runtime exception? You could apply required changes to one of our demos, if you don't want share your application.

All the best,
Alex


Post by alex.l »

We had similar problems in past, but all fixed since version 5.2.5
https://github.com/bryntum/support/issues/5977
https://github.com/bryntum/support/issues/5668

All the best,
Alex


Post Reply