Prepopulating Advanced Form fields on click

7 posts, 0 answers
  1. Dmitri
    Dmitri avatar
    12 posts
    Member since:
    May 2011

    Posted 23 Feb Link to this post

    I am trying to prepopulate certain data in the advanced form client side. Regardless of what I do when the form opens the subject field is blank and i get the validation warning to enter a subject...

    Here is my code can you please tell me what i am doing wrong and thanks

    <script type="text/javascript">
        function AdjustHeader(obj, args) {
            if (args.get_item().get_text().indexOf('Availability') > 0)
                formatAppointment(true);
            else if (args.get_item().get_text().indexOf('Class') > 0)
                formatAppointment(false);
        }
        function formatAppointment(isPriv) {
            $(".rsAllDayWrapper").hide();
            var subjectJQueryObject = $telerik.$("[id$='Form_Subject']");
            var subjectRadTextBoxObject = $find(subjectJQueryObject.attr("id"));
            alert(subjectJQueryObject.attr("id"));
            if (isPriv) {
                $(".rsAdvTitle").html("New Private Session Availability");
                subjectRadTextBoxObject.set_value("Open for private training");
                $("#" + idPrefix + "Subject_Label").html(" ")
            } else {
                $(".rsAdvTitle").html("New Group Class");
                $("#" + idPrefix + "Subject_Label").html("Class Name")
            }
        }
    </script>

    <telerik:RadScheduler RenderMode="Lightweight" runat="server" ID="schedTrainer" Height="590" OverflowBehavior="Auto"
        SelectedView="WeekView" ShowFooter="false" FirstDayOfWeek="Monday" LastDayOfWeek="Sunday"
        EnableDescriptionField="true" AppointmentStyleMode="Default" Skin="Telerik"
        OnResourcesPopulating="schedTrainer_ResourcesPopulating" OnClientResourcesPopulating="popUser"
        OnClientAppointmentsPopulating="popUser" OnClientAppointmentWebServiceDeleting="popUser"
        OnClientAppointmentWebServiceUpdating="popUser" OnClientAppointmentWebServiceInserting="popUser"
        StartEditingInAdvancedForm="true" StartInsertingInAdvancedForm="true"
        DayView-ShowAllDayInsertArea="false" MultiDayView-ShowAllDayInsertArea="false" WeekView-ShowAllDayInsertArea="false"
        ShowAllDayRow="false"               
        OnClientTimeSlotContextMenuItemClicking="AdjustHeader"
        >
        <AdvancedForm EnableResourceEditing="false" />
        <TimeSlotContextMenus>
            <telerik:RadSchedulerContextMenu runat="server" ID="TimeContextMenu">
                <Items>
                    <telerik:RadMenuItem Text="Add Recurring Availability" Value="CommandAddRecurringAppointment" />
                    <telerik:RadMenuItem Text="Add Recurring Class" Value="CommandAddRecurringAppointment" />
                    <telerik:RadMenuItem IsSeparator="True" />
                    <telerik:RadMenuItem Text="Add Spot Availability" Value="CommandAddAppointment" />
                    <telerik:RadMenuItem Text="Add Spot Class" Value="CommandAddAppointment" />
                    <telerik:RadMenuItem IsSeparator="True" />
                    <telerik:RadMenuItem Text="Go to today" Value="CommandGoToToday" />
                    <telerik:RadMenuItem Text="Show 24 hours..." Value="CommandShow24Hours" />
                </Items>
            </telerik:RadSchedulerContextMenu>
        </TimeSlotContextMenus>
        <WebServiceSettings Path="../../WebService/Scheduler.asmx" ResourcePopulationMode="ClientSide" />
        <AdvancedForm Modal="true"></AdvancedForm>
        <TimelineView UserSelectable="false"></TimelineView>
        <AgendaView UserSelectable="true" />
        <ResourceStyles>
            <%--AppointmentStyleMode must be explicitly set to Default (see above) otherwise setting BackColor/BorderColor
        will switch the appointments to Simple rendering (no rounded corners and gradients)--%>
            <telerik:ResourceStyleMapping Type="Calendar" Text="Personal"
                BorderColor="#abd962" />
            <telerik:ResourceStyleMapping Type="Calendar" Text="Work"
                BorderColor="#25a0da" />
        </ResourceStyles>
        <ResourceHeaderTemplate>
            <div class="rsResourceHeader<%# Eval("Text") %>">
                <%# Eval("Text") %>
            </div>
        </ResourceHeaderTemplate>
        <TimeSlotContextMenuSettings EnableDefault="true" />
        <AppointmentContextMenuSettings EnableDefault="true" />
        <Localization HeaderWeek="Work week" />
    </telerik:RadScheduler>

  2. Mehmet
    Mehmet avatar
    100 posts
    Member since:
    Jun 2014

    Posted 23 Feb Link to this post

    Hi Dmitri,

    Cannot you pass the data ID to the AdvancedForm and capture and bind the information calling from the database by the ID ? 
    This is what I do:

    1.function AppointmentEditing(sender, eventArgs) {
    2.                    var apt = eventArgs.get_appointment();
    3.                    window.radopen("AdvancedForm.aspx?jID=" + apt._id, "EditForm");
    4.                    eventArgs.set_cancel(true);
    5.                }

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mehmet
    Mehmet avatar
    100 posts
    Member since:
    Jun 2014

    Posted 23 Feb in reply to Dmitri Link to this post

    Hi Dmitri,

    Cannot you pass the ID through to the AdvancedForm and re-bind the information onto it by calling from the DB?
    I am having a similar case and I gotta bind some other information on the AdvancedForm popup so retrieve all from the DB.

  5. Dmitri
    Dmitri avatar
    12 posts
    Member since:
    May 2011

    Posted 23 Feb Link to this post

    The problem is the system seems to be ignoring 

    subjectRadTextBoxObject.set_value("Open for private training");

    as that doesnt seem to do anything despite the fact that the object is correct (i verified the ID) and this is from the documentation provided by Telerik on how to interact, client-side, with the advanced from fields...

  6. Mehmet
    Mehmet avatar
    100 posts
    Member since:
    Jun 2014

    Posted 23 Feb in reply to Dmitri Link to this post

    I understand your point.

    Btw, I have noticed that you are calling the web service to bind the data on the scheduler
    Are u experiencing any performance issue so far?

  7. Dmitri
    Dmitri avatar
    12 posts
    Member since:
    May 2011

    Posted 23 Feb in reply to Mehmet Link to this post

    Not in my DEV environment but havent tested in a production environment yet. In DEV it runs very smoothly and I am able to trap breakpoints in the webservice without issue...
  8. Mehmet
    Mehmet avatar
    100 posts
    Member since:
    Jun 2014

    Posted 23 Feb in reply to Dmitri Link to this post

    In the dev environment all can be smooth but when it gets to the prod level, also binding lots of information ( 3 months old - 6 months ahead in my case) that gets heavier with the resources that you have on the scheduler.
    I am investigating whether I can only load the current month data and it gets reloaded once the month is navigated through previous-next one.  It appears that It doesn't come up the right date range for each click on the scheduler(previous, next, calendar selection, day,week, month etc.). 
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017