search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

How to get all events by Resource

Asked by Ben
3 years ago.

Hi,

How can a find a delete all events by a Resource. I found this response from 5 years ago, but I cannot find any reference for findRowByResourceId in the Documentation.

Answer posted by Dan Letecky [DayPilot]
5 years ago.
On the client-side, you can do the following:

var hasEvents = dps.findRowByResourceId("A").events.length > 0;
On the server side, there is no internal structure that keeps events matched to the resources. You would have to go through the data source (you can reuse what you assign to DataSource property, so you don't have to load everything from the database twice).

See also the following tutorial that filters resources depending on the associated events. It works the other way - i.e. it shows only the free rows but you should be able to adjust the SELECT command as needed:

http://code.daypilot.org/34704/restaurant-table-reservation-tutorial-asp-net-c-vb-net

Answer posted by Dan Letecky [DayPilot]
3 years ago.

Ben,

You can get a list of all events like this:

var events = dp.rows.find("A").events.all();

And delete them:

dp.rows.find("A").events.all().forEach(function(e) { 
  dp.events.remove(e); 
});

See also:
https://api.daypilot.org/daypilot-scheduler-rows-find/
https://api.daypilot.org/daypilot-row-events-all/

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.