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

Issues to preserve dataset on month view navigation changes

Asked by Luis
10 years ago.

We are having issues when changing selection on month view navigation.
We are filtering by date start and end on month navigation as in the examples and by an employee with a dropdown.
If we change our employee selection after the page loads, it loads the events correctly. However if we change the month selection and go back to the initial selection our employee filter is lost so we have all the events for that month.
This issue has been seen in production environment however seems to work fine on development environment.
Have you seen or heard something like that? Any suggestion?
In the screenshots you can see how we have one event and when we go to another month and then we come back we have two events (it shows all the events for that month w/o filtering by employee)

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

How do you implement the filter?

The recommended way to is store the filter in .clientState and update the calendar using .commandCallBack().

  $(document).ready(function() {
    $("#dropdown").change(function() {
      // store the dropdown value in clientState
      dp.clientState.filter = $(this).val();
      // refresh the calendar
      dp.commandCallBack("refresh");
    });
  });

This will fire Command event on the server side with e.Command set to "refresh".

The filter value can be read using .ClientState:

string filterType = (string) DayPilotMonth1.ClientState["filter"];

Note that clicking the navigator will fire the Command event handler as well but this time with e.Command set to "navigate".

You should refresh the monthly calendar in the Command event handler (i.e. load events from the database, assign the event set to DataSource, call DataBind() and Update()) for both e.Command values. You need to apply the filter in both cases.

This kind of filter is implemented in the Shift Scheduling Tutorial:
http://code.daypilot.org/34377/shift-scheduling-tutorial-asp-net-sql-server-c-vb-net

See the "Assignments by Location" and "Assignments by Person" section. They are both implemented the same way.

See also:
http://doc.daypilot.org/month/clientstate/

Let me know if it didn't help.

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