Premium support for our pure JavaScript UI components


Post by Phil234234234234 »

Hello

On the Salesforce platform, we are trying to dynamically add entries to combos in editors for various components (Scheduler/Taskboard/Calendar). I've added a picture to show what we're trying to do (ie when a user types in the letters 'an', we want to dynamically add other options on the dropdown by adding these options to the store. We've already gotten it working for our Grid - but we've hit problems when trying to adopt the same solution for the other components (all of which use event editors).

However in doing so we are getting a crash from the Bryntum bundle we use (all.lwc.js). The error is TypeError: Cannot read properties of undefined (reading 'get')

I've added a picture of the stack trace. Specifically it crashes on line 35242 on

existingItem  = idIndex.get(id) 

. It crashes because idIndex is undefined and idIndex comes from me.idProperty which is declared at the top of the splice method.

The code we're trying to write is very simple - we just want to add a record to the combo box store dynamically. ie

config.listeners = {
		input: ({ source, value }) => {
			source.store.add([{ name: 'testy' }]);
	        };

Unfortunately we've not been able to yet replicate this on the Bryntum forums - but we will keep trying and we were wondering if anyone here had any immediate ideas as to what was going wrong (AKA - why would the 'me.idProperty' inside the splice method suddenly be undefined when we try adding new records to this store).

Thanks!
Philip

Attachments
Screenshot 2022-10-07 at 16.41.40.png
Screenshot 2022-10-07 at 16.41.40.png (308.57 KiB) Viewed 146 times
Screenshot 2022-10-07 at 16.47.55.png
Screenshot 2022-10-07 at 16.47.55.png (69.6 KiB) Viewed 146 times

Post by alex.l »

Hi Phil234234234234,

Yeh, we need more context to help you with that. I don't think it's related to Salesforce at all. Please try to collect more information regarding to the problem.

What idProperty is equals to? I see only name property in object you dynamically added.

Specifically it crashes on line 35242 on

I don't see this line in your screenshot.

All the best,
Alex


Post by Phil234234234234 »

Hi alex!

Actually after some deep diving, I think you can ignore this post. Essentially we were doing a full refresh of the dropdown contents inside our beforeEventEditShow listener for that dropdown. ie

	item.store = {
		...item.store.config,
		data: this.availableResources
	};

And this led to the side effect described above. We've gone for a new solution of manually clearing out the store and re-adding items when we need to. ie

	item.store.removeAll(false);
	item.store.add(dataToAddToStore);

which seems to avoid the above error being thrown. Given that that seems to be a decent workaround, I don't think we need any more guidance - but thanks for the help!


Post by alex.l »

Got it, thank you for the update!
Good luck!

All the best,
Alex


Post Reply