How to set TimelineView-StartTime property in JavaScript/MVC

7 posts, 0 answers
  1. Kushil
    Kushil avatar
    6 posts
    Member since:
    Mar 2011

    Posted 10 May 2011 Link to this post

    Hi all
    I am developing an ASP.NET MVC application. I have radScheduler in one page connected to a web service which pulls appoinments from the database. There are different appoinment types and there is one appoinment which can be moved across time slots. I need to show that appoinment in the scheduler when the page is loaded(initially and dynamically with other client side events). In order to do that I need to set "TimelineView-StartTime" property. It is a serverside property and I cannot find the corresponding JavaScript property. Since this is an MVC application I cannot set the property within server side tags. Could you please tell me how to set this "TimelineView-StartTime" property in ASP.NET MVC application dynamically? I cannot find the corresponding JavaScript property.
    Thanks in advance
    Kushil
  2. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 10 May 2011 Link to this post

    Hi Kushil,

    You can access the TimelineView settings of the RadScheduler via the get_timelineViewSettings() client-side method of the scheduler object. Also you can use the set_timelineViewSettings() method to set the StartTime of the TimelineView.

    Best wishes,
    Veronica Milcheva
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. Kushil
    Kushil avatar
    6 posts
    Member since:
    Mar 2011

    Posted 10 May 2011 Link to this post

    Hi Veronica
    Thanks very much for your response. I am so glad to know that it is possible.
    Could you please give me a sample code to use  set_timelineViewSettings() method to set the StartTime of TimelineView?
    I know that I can get the JavaScript object of the scheduler like this.
    var scheduler = $find('<%= RadScheduler1.ClientID %>');

    After that I am not sure how I should use set_timelineViewSettings() method to set the StartTime.

    I would really appreciate if you could respond to this.
    Thanks again
    Kushil
  4. Kushil
    Kushil avatar
    6 posts
    Member since:
    Mar 2011

    Posted 10 May 2011 Link to this post

    Ok, Veronica. I found a way. It is

    var scheduler = $find('<%= RadScheduler1.ClientID %>');
    scheduler.get_timelineViewSettings().startTime = 3600000;

    But I still do not know how to use set_timelineViewSettings() method.
    Thanks very much for your help.


  5. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 17 May 2011 Link to this post

    Hi Kushil,

    Please accept my apologies for misleading you.

    Actually you can not set the StartTime property of the TimelineView client-side. The reason is that the RadScheduler is already rendered and any settings that cause change of the rendering would not take effect on the client. As a workaround I'll offer you to use the OnAjaxRequest method of the AjaxManager.

    Regards,
    Veronica Milcheva
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  6. Kushil
    Kushil avatar
    6 posts
    Member since:
    Mar 2011

    Posted 20 Jun 2011 Link to this post

    Thanks Veronica.
    I tried this. But I am getting the following error when I call "ajaxRequest()" method.
    "Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled"
    Is it because ASP.NET MVC does not support postbacks (even async) as mentioned in here?
    http://forums.asp.net/t/1258905.aspx/1?Sys+WebForms+PageRequestManagerParserErrorException

    It seems like we cannot hook anything up to a server side event in MVC.

    And in a seperate note I would like to say that the following works in the client side.
    var scheduler = $find('<%= RadScheduler1.ClientID %>'); 
    scheduler.get_timelineViewSettings().startTime = 3600000;

    I can set startTime in clientside and the scheduler renders again when I call the following from clientside.
    scheduler.set_selectedDate(date);   //date is a valid date from seperate a datePicker
    But I also need to set the "numberOfSlots" property in radScheduler which Telerik client side api does not allow me to do. The following is the way I tried.
    var sch = $find('<%= RadScheduler1.ClientID %>'); 
    sch.get_timelineViewSettings().startTime = data.operatingHoursStart; //data is JSON return object
    sch.get_timelineViewSettings().slotDuration = data.BlockDuration; //data is JSON return object
    sch.get_timelineViewSettings().numberOfSlots = data.NoOfSlotsPerDay;      // data is JSON return object.
                                                                              // NoOfSlotsPerDay property has got a value like 8 (abosolute even number) 
    sch.set_selectedDate(date);     //Render Scheduler again. 
                                    //date is a valid date from a seperate datePicker 

    The above changes start time and slot duration. But it does not change the number of slots  in scheduler when it is re-rendered. The scheduler shows only three slots(two time heading boxes where firest one got two slots) which is the default. But when I inspect the numberOfSlots property in scheduler JavaScript object I can see that it has correctly been set to a different value. Is this a bug in scheduler?
    As an alternative when I set endTime (in miliseconds) instead of numberOfSlots and call set_showFullTime(true) I get the following error in Telerik's dynamically generated javascript.

    Microsoft JScript runtime error: '0.rows' is null or not an object

    Then I set ShowFullTime=True in design time (server property). It still shows only 3 slots (two time heading boxes) which is the default in radScheduler.

    Please help me.

    Thanks in advance
    Kushil
  7. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 24 Jun 2011 Link to this post

    Hello Kushil,

    Please accept my apologies for misleading you.

    After further consulting with the Ajax Team - the result is that you can not use AJAX Request in the MVC application as you found on your own. Unfortunately as I answered in my previous post - change of the NumberOfSlots requires re-rendering of the RadScheduler which can not be done client-side as the control is already rendered then.

    Please accept my apologies for the caused inconvenience and let me know if I can help you with anything else.

    All the best,
    Veronica Milcheva
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top