Our pure JavaScript Scheduler component


Post by shivambryntum01 »

Hi,
There seems to be some issue with resource view order. The initial resources are loaded correctly, but after appyling server side sorting or updating the resources, the resources order is not changing even if the state value gets updated. I am using bryntum scheduler react wrapper in nextjs using @bryntum/scheduler-react. Can you try to check if the same is happening for the following updates. I am maintaining a separate state for resources and events and just passing them as props. I am just sharing a small snippet here using which you can reproduce the issue. Also, i am not passing any custom sort method to resourceStore.
The same works fine when i pass resources directly into resourceStore as follows:
resourceStore={{data:resources}} but this causes some rerendering issues with large data.

let dummyResources=[
	{ id: 'r1', name: 'test1', role: 'test1' },
	{ id: 'r2', name: 'test2', role: 'test2' },
	{ id: 'r3', name: 'test3', role: 'test3' };
	]
	const [resources, setResources]= useState<any>(dummyResources);
return (<>
<button onClick={()=>{
setResources([...dummyResources.reverse()])
}}>Update</button>
			<BryntumScheduler
				ref={scheduler}
				{...defaultProps}
				resources={resources}
				events={events}
				/>
		</>
		)

Post by marcio »

Hello shivambryntum01,

We actually have a demo just for that state usage, you can check it here https://bryntum.com/products/scheduler/examples/frameworks/react/javascript/react-state/build/ and we don't have any type of reorder issue. Could you please assemble a sample project (you can create one based on the demo, just with your data) and then share it here?

Best regards,
Márcio


Post by shivambryntum01 »

Hi marcio,
I noticed one thing in the above demo url you shared is the dummy resources data list have same staff names but have different ids in each list. So on selecting a dataset - based on the id, its getting ordered correctly. In my case the id and other details remain exactly same but the order gets changed in state(as in the above snippet) which does not reflect in the column view. With the above demo you shared, instead of changing the ids, just change the order of the first list and keep it as Dataset 1. I tried the same and its not updating the view order. Correct me if i am wrong, i think resources get updated based on the id after comparing it with the existing resouce id.

Please try replacing the below dataset for resources in the above demo and you might be able to reproduce the issue on your end.

resources: [
    [
      { id: "r1", name: "Mike" },
      { id: "r2", name: "Linda" },
      { id: "r3", name: "Chang" },
      { id: "r4", name: "Kate" },
      { id: "r5", name: "Lisa" },
      { id: "r6", name: "Steve" },
      { id: "r7", name: "Mark" },
      { id: "r8", name: "Madison" },
      { id: "r9", name: "Hitomi" },
      { id: "r10", name: "Dan" },
    ],
    [
      // { id: 'r1', name: 'Mike' },
      // { id: 'r2', name: 'Linda' },
      // { id: 'r3', name: 'Lisa' },
      // { id: 'r4', name: 'Madison' },
      // { id: 'r5', name: 'Mark' },
      // { id: 'r6', name: 'Kate' },
      // { id: 'r7', name: 'Dan' },
      // { id: 'r8', name: 'Henrik' },
      // { id: 'r9', name: 'Rob' },
      // { id: 'r10', name: 'Gloria' }
      { id: "r6", name: "Steve" },
      { id: "r7", name: "Mark" },
      { id: "r8", name: "Madison" },
      { id: "r9", name: "Hitomi" },
      { id: "r10", name: "Dan" },
      { id: "r1", name: "Mike" },
      { id: "r2", name: "Linda" },
      { id: "r3", name: "Chang" },
      { id: "r4", name: "Kate" },
      { id: "r5", name: "Lisa" },
    ],
    ...
    ]

Post by marcio »

Hey, thanks for clarifying that, I created a ticket to check this - https://github.com/bryntum/support/issues/6039

Best regards,
Márcio


Post Reply