Loading events for users

Hi,

I want each personm using my system to have their own sxcheduler.

This will be achieved by sending an id to the scheduler page, which i can do through the routing. However, is there a way of passing this id into the call to dynamically load the data?

public ContentResult Data()
        {
            // needs to get the serviceuserid
            int serviceuser = 1;
            
            var data = new SchedulerAjaxData((new ScheduledEventsContext()).RetrieveEvents(userId));
            data.DateFormat = "%d/%m/%Y %H:%i";
            return data;
        }

Regards

Hello,
you can pass user id to the data url

scheduler.DataAction = string.Format("Data?userId={0}", "1"); and you’ll be able to retrieve it inside the data action

public ActionResult Data() { var userId = this.Request.QueryString["userId"];

How do i pass the id loaded in the index to the Save action event? There doesn’t appear to be away to return it to the index page so i can retrieve it and duplicating the DataAction method for SaveAction does not work as a querty string is not generated.

Regards

You may pass values using query string. If you don’t specify url explicitly, you still can add it to the scheduler configuration

sched.Data.DataProcessor.AddParameter("userId", value);//value will do to the Save action sched.Data.Loader.AddParameter("userId", value);//value will go to the Data action
another option is to store userId value in cookies

Hi,

I have added this, but the querystring is empty when the ActionResult for Save is accessed.


public actionresult Index(int id_)
{
         sched.Data.DataProcessor.AddParameter("userId", id_);//value will do to the Save action
         sched.Data.Loader.AddParameter("userId",id_);//value will go to the Data action
}

public ActionResult Save(RetrieveEventsByIdResult changedEvent, FormCollection actionValues)
{
            int user = int.Parse(Request.QueryString["userId"]);
}

Is there something else that needs to be done?

Hi,

DHXScheduler.Data.DataProcessor.AddParameter(string name, object value)

this method will add parameter to the saveAction url, and rendered url will look like
“saveActionUrl?name=value”. Parameter ‘name’ should be accessable in QueryString collection inside the action.
I’m not sure what goes wrong there,
but anyway, you still can use cookies to pass this parameter
Index:

Response.SetCookie(new HttpCookie("userId", serviceUserId.ToString()));

Save:

string clientId = Request.Cookies.Get("userId").Value;