Our pure JavaScript Scheduler component


Post by Aniket »

Team,

I am trying to call a custom method in the context menu of the event in the scheduler but it doesnt mae a call to the function.

   eventContextMenuFeature : {
    items: {
        deleteEvent: false,
        eventEdit: false,
        Redirect: {
          text: 'FindIn:',
          icon: 'b-fa b-fa-fw b-fa-search',
          onItem({ eventRecord }) {
            const testId = eventRecord.id;
          findRecord(testId);                             // OnItem of scheduler does not call custom method
           
}, } }

Post by alex.l »

Hi Aniket,

I tried it using our Angular example and it works fine. Could you try to reproduce it using this example as a base (it already has custom menu item, you just need to add some code into the handler): https://bryntum.com/examples/scheduler/angular/drag-from-grid/dist/drag-from-grid/index.html
Let us know how it works!

All best,
Alex

All the best,
Alex


Post by Aniket »

alex,

If you see my code above, I am not able to call a custom method in the onItem block of the contextMenu of event.

Hope you got my issue

Thanks.


Post by Maxim Gorkovsky »

I've tested it in angular and normal demos, works normally. Are you sure method is not called? Add a console.log(eventId) there and see if it gets logged?


Post by Aniket »

maxim, Onitem method gets called,

But inside the OnItem I am not able to call any custom method. For ex. findRecord(testId) is a custom method I am calling inside Onitem

 eventContextMenuFeature : {
    items: {
        deleteEvent: false,
        eventEdit: false,
        Redirect: {
          text: 'FindIn:',
          icon: 'b-fa b-fa-fw b-fa-search',
          onItem({ eventRecord }) {
            const testId = eventRecord.id;
          findRecord(testId);                             // OnItem of scheduler does not call custom method
           
}, } }

Post by Maxim Gorkovsky »

You need to make sure that findRecord fn is avaliable in the scope of the callback. How you do it is up to you, it depends on your app.


Post by sanid »

problem is binding to this context for component, that is possible with fat arrow syntax like so:

items.previousDay = {
          text: 'Bla bla',
          icon: 'b-fa b-fa-fw b-fa-arrow-left',
          onItem: (event)[b] => [/b]this.handleContextMenuMoveEvent(event, TaskMoveEnum.MOVE_TO_PREV_DAY)
        };

Post by mats »

So all working ok for you now?


Post Reply