Filtering events in timeline stops drawing a new event in DHTMLX

after filtering the events in timeline view , when i create a new event by dragging the mouse ,the onBeforeLightbox event is fired and i am able to access the event properties but the event is not visible on the scheduler.

Hello,

It probably happens because a new events doesn’t pass filtering criteria.

I think there are a couple of ways you can go from here.

You can either configure the default values of new events, so when a new event is created it would receive such initial values that would pass the filter that is currently active.
For example:

scheduler.attachEvent("onEventCreated", function(id,e){
    var event = scheduler.getEvent(id);
    // set such initial values so they would pass the filter that is currently active
    event.category_id = getFirstVisibleCategory();//getFirstVisibleCategory is a placeholder for this example, not a real method
    //any custom logic here
});

https://docs.dhtmlx.com/scheduler/api__scheduler_oneventcreated_event.html

Or you can go the other way and modify the filtering function, so it would always display new events while they are created, you can use drag drag_id flag for that:

scheduler.filter_timeline = function(id, event){
    var state = scheduler.getState();
    if(state.drag_id == id){
       return true;// always show event if it's being dragged and dropped
    }

    // apply your regular filters here
    return true;
}

https://docs.dhtmlx.com/scheduler/filtering.html
https://docs.dhtmlx.com/scheduler/api__scheduler_getstate.html

Finally, you can change the filter settings when user creates a new event.
I.e. when you detect that a new event is being created, you modify the filter expression from whatever it was set to to current filter + created event -

scheduler.attachEvent("onEventCreated", function(newId,e){
    var currentFilter = scheduler.filter_timeline;
    scheduler.filter_timeline = function(id, event){
       if(id == newId){
          return true;// always show new event
       }
       // use the current filter for the rest of events:
       return currentFilter.call(this, id, event);
    }
});

That way the user will be able to switch back to original filtering rule (and hide the new event) by selecting filtering rule again from the UI