Home Unanswered Active Tags New Question

DayPilotMonth: Filter Events using BeforeEventRender()?

My datasource contains events that I may want to filter-out under certain conditions. Is is possible to use the BeforeEventRender() to effectively 'cancel' the event?i.e. ....

e.Cancel = true;

...I know there's no cancel property on the event args, but can the same thing be achieved a different way? set the innerHTML to String.Empty perhaps? or maybe set the Start and End time to exactly the same Date/Time?

Asked by Simon Edwards 4 years ago.
Replies
First off, Start and End are ReadOnly so no changing there in the BeforeRender!

But what you are trying to do is reverse the whole logic... as you seem to have a parameter to filter things in the BeforeRender, why not filter it out in your datasource? Change your select query and filter them out before they are presented to the control!

Or you could always clear out the innerhtml and/or change the backgroundcolor

just put it in the beforeRender

if ('condition to filter')
   e.innerHTML = "";


hope this makes some sense

Comment posted by Lauwens 4 years ago.
Woops, sorry wrong 'pre' use there made the layout bit stretch
Comment posted by Lauwens 4 years ago.
Yes, Lauwens is correct: I recommend doing the filtering in the datasource. You have two choices:
  • Filter it using the SQL query (or stored procedure)
  • Replace SqlDataSource with a SqlDataAdapter.Fill() call and manual DataTable processing.
If you set e.InnerHTML = String.Empty in BeforeEventRender it will still render the event box.
Comment posted by Dan Letecky 4 years ago.
New Reply
This reply is
Your name (optional):

DayPilot for ASP.NET WebForms, DayPilot for ASP.NET MVC, DayPilot for Java