DayPilot Knowledge Base

AJAX Calendar/Scheduling Controls
DayPilot Pro (AJAX Calendar Control)
» DayPilot ASP.NET Calendar
DayPilot Pro (AJAX Monthly Calendar Control)
» DayPilot ASP.NET Monthly Calendar
DayPilot Pro (AJAX Scheduler Control)
» DayPilot ASP.NET Scheduler
DayPilot » Knowledge Base » How to use clientState property

How to use clientState property

Last revision: May 17, 2012

On the client side, you can save the state of all helping controls (typically filters) to .clientState property.

Whatever you assign to this property on the client side is sent to the server with all the CallBacks (and accessible as ClientState). In this example, clientState is used to send the text from the filter input box with all the requests so the results can be filtered properly.

Objects assigned to clientState are transformed to JsonData objects (see also Sending custom data with callback).

Example (set the client state in JavaScript):

dps1.clientState.filter = "sales";

Example (read the client state on the server side):

string filter = (string) DayPilotScheduler1.ClientState["filter"];

Complex objects

The clientState object will be serialized using a modified json.org serializer.

You should avoid adding complex objects with deep children structures and circular references.

Serialization of complex objects can be handled by providing toJSON() method:

var r = {};
r.root = calendar; // to be skipped during serialization
r.filter = 'text';
r.toJSON = function(key) {
  var json = {};
  json.filter = this.filter;
  return json;
};

dps.clientState = r;

See also

Related

How to add an event to the scheduler on the client side (JavaScript)
How to implement fast AJAX event filtering in the calendar
How to show the selected date using a Label control
How to open a new event dialog using TimeRangeSelected event (modal.js)