html5 monthly event calendar filtering

JavaScript

DayPilot Month supports client-side event filtering since build 8.2.2224.

  • Use onEventFilter event handler to implement the filtering rule.
  • Use events.filter(param) to filter the events using the supplied parameter.
<div class="space">
  Filter: <input id="filter" /> <a href="#" id="clear">Clear</a>
</div>

<div id="dp"></div>

<script>

  var dp = new DayPilot.Month("dp");
  // ...
  dp.onEventFilter = function(args) {

    // display only events that contain the specified text, case insensitive
    if (args.e.text().toUpperCase().indexOf(args.filter.toUpperCase()) === -1) {
      args.visible = false;
    }
  };
  dp.init();

  $(document).ready(function() {
      $("#filter").keyup(function() {
          var query = $(this).val();
          dp.events.filter(query); 
      });

      $("#clear").click(function() {
          $("#filter").val("");
          dp.events.filter(null);
          return false;
      });
  });
</script>

ASP.NET WebForms

Use ClientState to persist the filter parameters. 

You can store the filter settings in .clientState property on the client side:

dpm.clientState.filterText = 'text';
dpm.clientState.filterType = 'finished';

ClientState is persisted and updated with every callback (until you reload the page) and it's accessible on the server side.

string filterText = (string) DayPilotMonth1.ClientState["filterText"];
string filterType = (string) DayPilotMonth1.ClientState["filterType"];
DayPilotMonth1.DataSource = LoadData(filterText, filterType); DayPilotMonth1.DataBind(); DayPilotMonth1.Update();

ASP.NET MVC

Use ClientState to persist the filter parameters. 

You can store the filter settings in .clientState property on the client side:

dpm.clientState.filterText = 'text';
dpm.clientState.filterType = 'finished';

ClientState is persisted and updated with every callback (until you reload the page) and it's accessible on the server side.

string filterText = (string) ClientState["filterText"];
string filterType = (string) ClientState["filterType"];

Events = LoadEvents(filterText, filterType);
Update();