JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Scheduler › How to manipulate an event before it gets saved to the localstorage
- This topic has 4 replies, 2 voices, and was last updated 2 years, 4 months ago by svetoslav_borislavov.
-
AuthorPosts
-
July 21, 2022 at 3:32 pm #103420Ojo NjokuParticipant
Hi guys, please how can i manipulate the data before it gets saved to the localstorage. for example, i want to add a condition before the item gets saved into the localstorage, and inserted to the scheduler. i’ve tried onSubmit method, onItemInsert but the data has already been saved to the localstorage which is not what i want.
Also how can i remove some fields from the create event modal? i really do not need all the fields and i would love to clean it up.
Any help, please?
July 22, 2022 at 7:12 am #103421svetoslav_borislavovParticipantHi,
Can you explain what are you trying to achieve?
You can edit the event object in the itemChanging event.
This event is triggered when an Event is GOING to be updated/inserted/removed. This event allows to cancel the operation by calling event.preventDefault() in the event handler function.
event.detail.type contains the type of the operation. You can use this to check if it is ‘inserting’.
event.detail.item contains the event object that you can manipulate.Please explain your situation so we can help you!
Please have a look at this demo to see how to hide any datafield in the modal: codepen
Basically, the event object from the editDialogOpen event contains all the editors in ‘event.detail.editors’.
From there you can get any editor you want and apply a class ‘smart-hidden’: ‘notificationsEditor.classList.add(‘smart-hidden’);’Best Regards,
Svetoslav BorislavovSmart UI Team
https://www.htmlelements.com/July 22, 2022 at 9:24 am #103422Ojo NjokuParticipantthanks so much for your reply. the event itemChanging gives me what i want just like you adviced. but then i noticed that when inserting an event, i dont have access to the label value, only when the event is updating, or when i use the onItemInsert event.
how can i access the label value within the itemChanging event?
July 22, 2022 at 9:32 am #103423Ojo NjokuParticipantam sorry, i mistakenly added a new comment instead of replying to your response
July 25, 2022 at 9:26 am #103424svetoslav_borislavovParticipantHi,
As a workaround, you can declare a variable which will store the input element of the label.
In the handler of the editDialogOpen event, you will initialize the variable with the reference of the label input element and in the ItemChanging event you can access the value of the input element. This can be done for any element.Here is an example: https://codepen.io/svetoslavb04/pen/rNdwxOd
If you need any help, do not hesitate to contact us!
Best Regards,
Svetoslav BorislavovSmart UI Team
https://www.htmlelements.com/ -
AuthorPosts
- You must be logged in to reply to this topic.