Setting Attribute from Context Menu

6 posts, 0 answers
  1. Steven
    Steven avatar
    27 posts
    Member since:
    May 2012

    Posted 18 Apr 2013 Link to this post

    I am trying to toggle an attribute (IsLocked) from the context menu.  I've debugged and when it hits my breakpoint in the C# code, the appointment still shows IsLocked = false.   

    If I put a breakpoint on the JS (using Firebug) I see that these lines are working:
    selectedAppointment.get_attributes().setAttribute(LockedAttribute, toggleLock);
    scheduler.updateAppointment(selectedAppointment);
    //this also confirms it:
    alert("selected appointment value= " + selectedAppointment.get_attributes().getAttribute(LockedAttribute));
    alert(scheduler.get_appointments().findByID(1).get_attributes().getAttribute(LockedAttribute));

    However, by the time OnLoad runs server side code runs, a break point at the top shows that the IsLocked for the appointment is incorrect.

    What is happening between the end of the client code running and the start of the server side code?

    See below for relevant code.

    JS Code:
    function appointmentContextMenuItemClicked(sender, eventArgs) {
            try {
                var scheduler = $find("<%= schMasterScheduler.ClientID %>");
                var selectedAppointment = eventArgs.get_appointment();
                var clickedContextMenuItem = eventArgs.get_item();
                var LockedAttribute = "IsLocked";
     
                if (clickedContextMenuItem.get_text() == "Toggle Lock") {
                    var isLocked = selectedAppointment.get_attributes().getAttribute(LockedAttribute);
     
                    if (isLocked == "True")
                        toggleLock = "False";
                    else
                        toggleLock = "True";
     
                    selectedAppointment.get_attributes().setAttribute(LockedAttribute, toggleLock);
                    scheduler.updateAppointment(selectedAppointment);
                }
            }
            catch (e) {
                alert(e.Message);
            }

    ASPX Code:
            <telerik:RadScheduler runat="server"
                ID="schMasterScheduler"
                Width="1350px"    
                Height="540px"
                Skin="Web20"
                SelectedView="TimelineView"
                ColumnWidth="50px"                    
                DayStartTime="00:00:00"
                DayEndTime="23:59:59"
                ShowViewTabs="False"
                DataKeyField="BatchNumber"
                DataStartField="Start"
                DataEndField="End"
                DataSubjectField="Material"
                CustomAttributeNames=
                    "BatchNumber, BatchSize, UnitOfMeasureID, Duration, IsNonProdTime, MaterialID,
                    ShipDate, WashPrep, Priority, IsWorkOff, RawMaterialDependency, Comments, ProductionOrderID
                    ContainerType, ContainerQuantity, UnitOfMeasureName, IsDirty, IsLocked, IsNew"
                EnableDescriptionField="false"
                AppointmentStyleMode="Default"
                EnableResourceEditing="false"
                OverflowBehavior="Scroll"
                TimelineView-SlotDuration="06:00:00"
                TimelineView-GroupingDirection="Vertical"
                TimelineView-ShowDateHeaders="true"
                TimelineView-ColumnHeaderDateFormat="ddd<br/>MMM d<br/>H:00"
                TimelineView-HeaderDateFormat="dddd, MMMM dd, yyyy"
                TimelineView-ShowInsertArea="false"
                StartEditingInAdvancedForm="true"  
                StartInsertingInAdvancedForm="true"                   
                AdvancedForm-Modal="true"
                AdvancedForm-Enabled="true"
                AdvancedForm-EnableTimeZonesEditing="false"
                AdvancedForm-EnableCustomAttributeEditing="true"
                OnappointmentUpdate="schMasterScheduler_AppointmentUpdate"
                OnFormCreated="schMasterScheduler_FormCreated"        
                OnFormCreating="schMasterScheduler_FormCreating"
                onappointmentdelete="schMasterScheduler_AppointmentDelete"
                onappointmentdatabound="schMasterScheduler_AppointmentDataBound"
                OnAppointmentCancelingEdit="schMasterScheduler_AppointmentCancelingEdit"           
                TimeSlotContextMenuSettings-EnableDefault="true"
                AppointmentContextMenuSettings-EnableDefault="false"
                onnavigationcommand="schMasterScheduler_NavigationCommand"
                OnClientAppointmentContextMenuItemClicked="appointmentContextMenuItemClicked">            
     
               <AppointmentTemplate>           
                    <div class="appointmentTemplate">  
                    <%# Eval("Subject") %> | <%# Eval("BatchNumber") %>                 
                        <asp:Image id="imgLocked" runat="server" ImageUrl="~/_Layouts/Capgemini.BHI.Webparts/images/lock.png" ToolTip="Locked"  
                            Visible='<%# Convert.ToBoolean(Eval("IsLocked")) %>' CssClass="lock"></asp:Image>                   
                    </div>
                </AppointmentTemplate>
                             
                <AppointmentContextMenus>
                    <telerik:RadSchedulerContextMenu runat="server" ID="schMasterScheduleContextMenu">
                        <Items>
                            <telerik:RadMenuItem Text="Toggle Lock" Value="1"></telerik:RadMenuItem>
                        </Items>
                    </telerik:RadSchedulerContextMenu>
                </AppointmentContextMenus>
                                        
                <AdvancedEditTemplate>
                <div class="rsAdvancedEdit rsAdvancedModal">
                    <div class="rsModalBgTopLeft"></div>
                    <div class="rsModalBgTopRight"></div>
                    <div class="rsModalBgBottomLeft"></div>
                    <div class="rsModalBgBottomRight"></div>    
                    <div class="rsAdvTitle">                 
                        <h1 class="rsAdvInnerTitle">Production Order Details</h1>           
                    </div>
                    <div class="rsAdvContentWrapper">
                        <div class="popUpDiv">
                            <h4>Required</h4>
                            <br />                     
     
                            <div class="required-left">
                                <label>Material #</label>
     
                                <%-- <telerik:RadComboBox runat="server" ID="ddlMaterial" MarkFirstMatch="true" EnableViewState="true"
                                    OnSelectedIndexChanged="ddlMaterial_SelectedIndexChanged" AutoPostBack="true" CausesValidation="false">
                                </telerik:RadComboBox> --%>
                                 
                                <telerik:RadTextBox runat="server" ID="txtMaterial" OnTextChanged="txtMaterial_TextChanged"
                                    AutoPostBack="true" EmptyMessage="Bulk Only" ClientEvents-OnKeyPress="RestrictSpace"></telerik:RadTextBox>
                                <telerik:RadComboBox runat="server" ID="ddlNonProdMaterials" EnableViewState="true" Visible="false"></telerik:RadComboBox>
                                <br />
     
                                <label>Batch #</label>
                                <telerik:RadTextBox runat="server" ID="txtBatchNumber" MaxLength="12" ClientEvents-OnKeyPress="RestrictSpace"></telerik:RadTextBox>
                                <br />                                                  
     
                                <%--<label>Batch Size</label>  
                                <telerik:RadNumericTextBox runat="server"
                                    ID="txtBatchSize"
                                    Width="97px"    
                                    EnableViewState="true"
                                    ShowSpinButtons="false"
                                    IncrementSettings-InterceptArrowKeys="false"
                                    IncrementSettings-InterceptMouseWheel="false"
                                    MinValue="0"   
                                    NumberFormat-DecimalDigits="0"
                                    Type="Number"
                                    AutoPostBack="true"
                                    OnTextChanged="txtBatchSize_TextChanged">                           
                                </telerik:RadNumericTextBox>
                                                     
                                <telerik:RadComboBox runat="server" ID="ddlUnitOfMeasure" Width="60px" EnableViewState="true"></telerik:RadComboBox>                           
                                <br />--%>                          
                                 
                                <label>Vessel</label>
                                <resource:ResourceControl runat="server" ID="ResVessel" Visible="false" />
                            </div>
                            <div class="required-right">
                                <label>Start Date</label>
                                <telerik:RadDateTimePicker runat="server"
                                    ID="dtpStartDateTime"
                                    SelectedDate='<%# Bind("Start") %>'  
                                    ShowAnimation-Type="Slide"
                                    ShowPopupOnFocus="true"
                                    Calendar-ShowOtherMonthsDays="false"
                                    Calendar-ShowRowHeaders="false"
                                    Width="160px"
                                    DateInput-DisplayDateFormat="M/d/yyyy - H:00"
                                    TimeView-RenderDirection="Vertical"
                                    TimeView-Columns="4"
                                    TimeView-TimeFormat="H:00"
                                    TimeView-ShowHeader="false"
                                    TimeView-Interval="6:00"
                                    TimeView-StartTime="00:00:00"
                                    TimeView-EndTime="23:59:00"
                                    DateInput-ClientEvents-OnKeyPress="RestrictSpace">                               
                                </telerik:RadDateTimePicker>
                                <br />
     
                                <label>Duration</label>
                                <telerik:RadNumericTextBox runat="server"
                                    ID="txtDuration"
                                    ForeColor="Black"
                                    ShowSpinButtons="true"
                                    IncrementSettings-InterceptArrowKeys="true"
                                    IncrementSettings-InterceptMouseWheel="true"
                                    IncrementSettings-Step="6"
                                    MinValue="6"   
                                    NumberFormat-DecimalDigits="0"
                                    Type="Number"
                                    Width="108px"
                                    AutoPostBack="false"
                                    ClientEvents-OnLoad="disableKeyboard">
                                </telerik:RadNumericTextBox>
                                <label class="right">Hours</label>
                                <br />
     
    <%--                            <label>Complete Date</label>
                                <telerik:RadDateTimePicker runat="server"
                                    ID="dtpEndDateTime"
                                    SelectedDate='<%# Bind("End") %>'
                                    ShowAnimation-Type="Slide"
                                    ShowPopupOnFocus="false"                                
                                    DatePopupButton-Visible="false"
                                    TimePopupButton-Visible="false"
                                    Width="108px"
                                    Enabled="false"
                                    DateInput-DisplayDateFormat="M/d/yyyy - H:00"
                                    TimeView-RenderDirection="Horizontal"
                                    TimeView-Columns="4"
                                    TimeView-TimeFormat="H:00"
                                    TimeView-ShowHeader="false"
                                    TimeView-Interval="6:00"
                                    TimeView-StartTime="00:00:00"
                                    TimeView-EndTime="23:59:00">   
                                </telerik:RadDateTimePicker>
                                <br />
                                 
                                <label> </label>
                                --%>                         
     
                            </div>
                        </div>
     
                        <div class="popUpDiv">
                            <h4>Containers</h4>
                            <div class="containers">                           
                                <asp:Repeater ID="rptContainering" runat="server" EnableViewState="true">
                                    <HeaderTemplate>
                                        <table id="containers-table">
                                    </HeaderTemplate>
                                    <ItemTemplate>  
                                            <tr>                                               
                                                <td><asp:Textbox runat="server" ID="lblMaterialContainer" Text='<%# Eval("MaterialContainer") %>'
                                                    Enabled="false" BorderStyle="None" ForeColor="Black" BackColor="White" Width="110px"></asp:Textbox></td>                                           
                                                <td><label>Quantity</label></td
                                                <td><telerik:RadNumericTextBox runat="server" ID="txtContainerQuantity" MinValue="0" NumberFormat-DecimalDigits="0"
                                                    IncrementSettings-InterceptArrowKeys="false" IncrementSettings-InterceptMouseWheel="false"
                                                    Width="55px" Text='<%# Eval("ContainerOrderQuantity") %>'></telerik:RadNumericTextBox></td>                                           
                                                <td><telerik:RadComboBox runat="server" ID="ddlUnitOfMeasure" Width="100px" EnableViewState="true" MarkFirstMatch="true"
                                                    EmptyMessage="Select UOM" Visible="false"></telerik:RadComboBox>
                                                <asp:Label runat="server" ID="lblContainerUOM" Visible="false" Text='<%# Eval("ContainerUnitOfMeasureName") %>'></asp:Label></td>
                                                <td><label>Vessel</label></td>
                                                <td><telerik:RadComboBox runat="server" ID="ddlContainerVessel" EmptyMessage="Vessel" Width="90px"></telerik:RadComboBox></td>
                                            </tr>
                                            <asp:HiddenField runat="server" ID="hiddenContainerType" Value='<%# Eval("ContainerType")%>'/>                                            
                                    </ItemTemplate>
                                    <FooterTemplate>
                                        </table>
                                    </FooterTemplate>
                                </asp:Repeater>                               
                            </div>
                        </div>
                 
                        <div class="popUpDiv" id="bottom">
                            <h4>Optional</h4>
                            <br />
     
                            <div class="optional-left">                          
                                <label>Locked</label>
                                <asp:CheckBox runat="server" ID="cbLocked" cssClass="checkbox" />
                                <br />
     
                                <label>Ship Date</label>
                                <telerik:RadDatePicker runat="server" ID="calShippingDate" Width="165px" DateInput-ClientEvents-OnKeyPress="RestrictSpace"
                                    ShowAnimation-Type="Slide" DateInput-DisplayDateFormat="M/d/yyyy" ShowPopupOnFocus="true">
                                </telerik:RadDatePicker>         
                                <br />
     
                                <label>Wash Prep</label>
                                <telerik:RadTextBox runat="server" ID="txtWashPrep" ClientEvents-OnKeyPress="RestrictTilde"></telerik:RadTextBox>
                                <br />
     
                                <label>Priority</label>
                                <telerik:RadComboBox runat="server" ID="ddlPriority" CssClass="dropdownlist"
                                    onclientselectedindexchanged="Priority_OnSelectedIndexChanged" EnableViewState="true">                        
                                    <Items>
                                        <telerik:RadComboBoxItem Value="0" Text="Choose Priority"/>
                                        <telerik:RadComboBoxItem Value="1" Text="Late Batch" BackColor="Red" />
                                        <telerik:RadComboBoxItem Value="2" Text="Complete for Tomorrow" ForeColor="Red" />
                                        <telerik:RadComboBoxItem Value="3" Text="2 Days from Now" ForeColor="DarkBlue" />
                                        <telerik:RadComboBoxItem Value="4" Text="Ships Within Next 7 Days" ForeColor="Blue" />
                                        <telerik:RadComboBoxItem Value="5" Text="Make to Stock" />                                   
                                    </Items>
                                </telerik:RadComboBox>
                                <br />
     
                                <label>Work Off</label>
                                <asp:CheckBox runat="server" ID="cbWorkOff" CssClass="checkbox"/>
                                <br />
     
                                <label class="wrap">Raw Material Dependency</label>
                                <telerik:RadTextBox runat="server" ID="txtRawMaterialDependency" ClientEvents-OnKeyPress="RestrictTilde"></telerik:RadTextBox>
                                <br />                         
                            </div>
                                                     
                            <div class="optional-right">
                                <label class="top-align">Comments</label>
                                <telerik:RadTextBox runat="server" ID="txtComments" CssClass="textbox-multiline" Rows="8"
                                   ClientEvents-OnKeyPress="RestrictTilde" TextMode="MultiLine" Width="200px"></telerik:RadTextBox>
                            </div>   
                                 
                        </div>
                        <asp:Panel runat="server" ID="pnlButtons" CssClass="rsAdvancedSubmitArea">
                            <div class="rsAdvButtonWrapper">
                                <asp:LinkButton CommandName="Update" runat="server" ID="btnUpdate" CssClass="rsAdvEditSave">
                                    <span>Save</span>
                                </asp:LinkButton>
                                <asp:LinkButton runat="server" ID="btnCancel" CssClass="rsAdvEditCancel" CommandName="Cancel" CausesValidation="false">
                                    <span>Cancel</span>
                                </asp:LinkButton>
                            </div>
                        </asp:Panel>
                    </div>
                </div>
                </AdvancedEditTemplate>
                 
                <AdvancedInsertTemplate>
                <div class="rsAdvancedEdit rsAdvancedModal">
                    <div class="rsModalBgTopLeft"></div>
                    <div class="rsModalBgTopRight"></div>
                    <div class="rsModalBgBottomLeft"></div>
                    <div class="rsModalBgBottomRight"></div>    
                    <div class="rsAdvTitle">                 
                        <h1 class="rsAdvInnerTitle">Production Order Details</h1>           
                    </div>
                    <div class="rsAdvContentWrapper">
                        <div class="popUpDiv">
                            <h4>Required</h4>
                            <br />
     
                            <div class="required-left">
                                <label>Material #</label>
     
                                <%-- <telerik:RadComboBox runat="server" ID="ddlMaterial" MarkFirstMatch="true" EnableViewState="true"
                                    OnSelectedIndexChanged="ddlMaterial_SelectedIndexChanged" AutoPostBack="true" CausesValidation="false">
                                </telerik:RadComboBox>--%>
                                 
                                <telerik:RadTextBox runat="server" ID="txtMaterial" OnTextChanged="txtMaterial_TextChanged"
                                    AutoPostBack="true" EmptyMessage="Bulk Only" ClientEvents-OnKeyPress="RestrictSpace"></telerik:RadTextBox>
                                <telerik:RadComboBox runat="server" ID="ddlNonProdMaterials" EnableViewState="true" Visible="false"></telerik:RadComboBox>
                                <br />                           
     
                                <label>Batch #</label>
                                <telerik:RadTextBox runat="server" ID="txtBatchNumber" MaxLength="12" ClientEvents-OnKeyPress="RestrictSpace"></telerik:RadTextBox>
                                <br />
     
                                <label>Vessel</label>                           
                                <resource:ResourceControl runat="server" ID="ResVessel" Visible="false" />
                                 
                                <%--                           
                                <label>Batch Size</label>  
                                <telerik:RadNumericTextBox runat="server"
                                    ID="txtBatchSize"
                                    Width="97px"    
                                    EnableViewState="true"
                                    ShowSpinButtons="false"
                                    IncrementSettings-InterceptArrowKeys="false"
                                    IncrementSettings-InterceptMouseWheel="false"
                                    MinValue="0"   
                                    NumberFormat-DecimalDigits="0"
                                    Type="Number"
                                    AutoPostBack="true"
                                    OnTextChanged="txtBatchSize_TextChanged">                           
                                </telerik:RadNumericTextBox>
                                                     
                                <telerik:RadComboBox runat="server" ID="ddlUnitOfMeasure" Width="60px" EnableViewState="true"></telerik:RadComboBox>                           
                                <br />--%>
               
                            </div>
                            <div class="required-right">
                                <label>Start Date</label>
                                <telerik:RadDateTimePicker runat="server"
                                    ID="dtpStartDateTime"
                                    SelectedDate='<%# Bind("Start") %>'  
                                    ShowAnimation-Type="Slide"
                                    ShowPopupOnFocus="true"
                                    Calendar-ShowOtherMonthsDays="false"
                                    Calendar-ShowRowHeaders="false"
                                    Width="160px"
                                    DateInput-DisplayDateFormat="M/d/yyyy - H:00"
                                    TimeView-RenderDirection="Vertical"
                                    TimeView-Columns="4"
                                    TimeView-TimeFormat="H:00"
                                    TimeView-ShowHeader="false"
                                    TimeView-Interval="6:00"
                                    TimeView-StartTime="00:00:00"
                                    TimeView-EndTime="23:59:00"
                                    DateInput-ClientEvents-OnKeyPress="RestrictSpace">                               
                                </telerik:RadDateTimePicker>
                                <br />
     
                                <label>Duration</label>
                                <telerik:RadNumericTextBox runat="server"
                                    ID="txtDuration"
                                    ForeColor="Black"
                                    ShowSpinButtons="true"
                                    IncrementSettings-InterceptArrowKeys="true"
                                    IncrementSettings-InterceptMouseWheel="true"
                                    IncrementSettings-Step="6"
                                    MinValue="6"   
                                    NumberFormat-DecimalDigits="0"
                                    Type="Number"
                                    Width="108px"
                                    AutoPostBack="false"
                                    ClientEvents-OnLoad="disableKeyboard">
                                </telerik:RadNumericTextBox>
                                <label class="right">Hours</label>
                                <br />
     
                                <%--<label>Complete Date</label>
                                <telerik:RadDateTimePicker runat="server"
                                    ID="dtpEndDateTime"
                                    SelectedDate='<%# Bind("End") %>'
                                    ShowAnimation-Type="Slide"
                                    ShowPopupOnFocus="false"                                
                                    DatePopupButton-Visible="false"
                                    TimePopupButton-Visible="false"
                                    Width="108px"
                                    Enabled="false"
                                    DateInput-DisplayDateFormat="M/d/yyyy - H:00"
                                    TimeView-RenderDirection="Horizontal"
                                    TimeView-Columns="4"
                                    TimeView-TimeFormat="H:00"
                                    TimeView-ShowHeader="false"
                                    TimeView-Interval="6:00"
                                    TimeView-StartTime="00:00:00"
                                    TimeView-EndTime="23:59:00">   
                                </telerik:RadDateTimePicker>
                                <br />      --%>                    
     
                                <label> </label>                          
                                <asp:LinkButton runat="server" ID="lbNonProd" OnClick="lbNonProd_Click" CausesValidation="false" Visible="true" Text="Schedule Non-Productive Time"></asp:LinkButton>
                                 
                            </div>
                        </div>
     
                        <div class="popUpDiv">
                            <h4>Containers</h4>
                            <div class="containers">                           
                                <asp:Repeater ID="rptContainering" runat="server" EnableViewState="true">
                                    <HeaderTemplate>
                                        <table id="containers-table">
                                    </HeaderTemplate>
                                    <ItemTemplate>  
                                            <tr>                                               
                                                <td><asp:Textbox runat="server" ID="lblMaterialContainer" Text='<%# Eval("MaterialContainer") %>' Width="120px"
                                                    Enabled="false" BorderStyle="None" ForeColor="Black" BackColor="White"></asp:Textbox></td>                                           
                                                <td><label>Quantity</label></td
                                                <td><telerik:RadNumericTextBox runat="server" ID="txtContainerQuantity" MinValue="0" NumberFormat-DecimalDigits="0"
                                                    IncrementSettings-InterceptArrowKeys="false" IncrementSettings-InterceptMouseWheel="false"
                                                    Width="55px" Text='<%# Eval("ContainerOrderQuantity") %>'></telerik:RadNumericTextBox></td>                                           
                                                <td><telerik:RadComboBox runat="server" ID="ddlUnitOfMeasure" Width="100px" EnableViewState="true" MarkFirstMatch="true"
                                                    EmptyMessage="Select UOM" Visible="false"></telerik:RadComboBox>
                                                <asp:Label runat="server" ID="lblContainerUOM" Visible="false" Text='<%# Eval("ContainerUnitOfMeasureName") %>'></asp:Label></td>
                                                <td><label>Vessel</label></td>
                                                <td><telerik:RadComboBox runat="server" ID="ddlContainerVessel" EmptyMessage="Vessel" Width="90px"></telerik:RadComboBox></td>
                                            </tr>
                                            <asp:HiddenField runat="server" ID="hiddenContainerType" Value='<%# Eval("ContainerType")%>'/>                           
                                    </ItemTemplate>
                                    <FooterTemplate>
                                        </table>
                                    </FooterTemplate>
                                </asp:Repeater>                               
                            </div>
                        </div>
                 
                        <div class="popUpDiv" id="bottom">
                            <h4>Optional</h4>
                            <br />
     
                            <div class="optional-left">                          
                                <label>Locked</label>
                                <asp:CheckBox runat="server" ID="cbLocked" cssClass="checkbox" />
                                <br />
     
                                <label>Ship Date</label>
                                <telerik:RadDatePicker runat="server" ID="calShippingDate" Width="165px" DateInput-ClientEvents-OnKeyPress="RestrictSpace"
                                    ShowAnimation-Type="Slide" DateInput-DisplayDateFormat="M/d/yyyy" ShowPopupOnFocus="true">
                                </telerik:RadDatePicker>         
                                <br />
     
                                <label>Wash Prep</label>
                                <telerik:RadTextBox runat="server" ID="txtWashPrep" ClientEvents-OnKeyPress="RestrictTilde"></telerik:RadTextBox>
                                <br />
     
                                <label>Priority</label>
                                <telerik:RadComboBox runat="server" ID="ddlPriority" CssClass="dropdownlist"
                                    onclientselectedindexchanged="Priority_OnSelectedIndexChanged" EnableViewState="true">                        
                                    <Items>
                                        <telerik:RadComboBoxItem Value="0" Text="Choose Priority"/>
                                        <telerik:RadComboBoxItem Value="1" Text="Late Batch" BackColor="Red" />
                                        <telerik:RadComboBoxItem Value="2" Text="Complete for Tomorrow" ForeColor="Red" />
                                        <telerik:RadComboBoxItem Value="3" Text="2 Days from Now" ForeColor="DarkBlue" />
                                        <telerik:RadComboBoxItem Value="4" Text="Ships Within Next 7 Days" ForeColor="Blue" />
                                        <telerik:RadComboBoxItem Value="5" Text="Make to Stock" />                                   
                                    </Items>
                                </telerik:RadComboBox>
                                <br />
     
                                <label>Work Off</label>
                                <asp:CheckBox runat="server" ID="cbWorkOff" CssClass="checkbox"/>
                                <br />
     
                                <label class="wrap">Raw Material Dependency</label>
                                <telerik:RadTextBox runat="server" ID="txtRawMaterialDependency" ClientEvents-OnKeyPress="RestrictTilde"></telerik:RadTextBox>
                                <br />                         
                            </div>
                                                     
                            <div class="optional-right">
                                <label class="top-align">Comments</label>
                                <telerik:RadTextBox runat="server" ID="txtComments" CssClass="textbox-multiline" Rows="8"
                                  ClientEvents-OnKeyPress="RestrictTilde" TextMode="MultiLine" Width="200px"></telerik:RadTextBox>
                            </div>   
                                 
                        </div>
                        <asp:Panel runat="server" ID="pnlButtons" CssClass="rsAdvancedSubmitArea">
                            <div class="rsAdvButtonWrapper">
                                <asp:LinkButton CommandName="Update" runat="server" ID="btnUpdate" CssClass="rsAdvEditSave">
                                    <span>Save</span>
                                </asp:LinkButton>
                                <asp:LinkButton runat="server" ID="btnCancel" CssClass="rsAdvEditCancel" CommandName="Cancel" CausesValidation="false">
                                    <span>Cancel</span>
                                </asp:LinkButton>
                            </div>
                        </asp:Panel>
                    </div>
                </div>
                </AdvancedInsertTemplate>
     
            </telerik:RadScheduler>

    C# Code:
    protected void schMasterScheduler_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e)
            {
                if (isFormOpen) //it wasn't a drag and drop
                {
                        //stuff
                }
               else //it's drag n drop, update
                {
                    ProductionRun modifiedRun = getProductionRunById(e.ModifiedAppointment.ID.ToString());
                     
                    //check to see if they moved it
                    if (modifiedRun.Start != e.ModifiedAppointment.Start || modifiedRun.End != e.ModifiedAppointment.End ||
                        modifiedRun.VesselID != e.ModifiedAppointment.Resources.GetResourceByType(PlantID).Key.ToString())
                    {
                         //do stuff
                    }
                }
  2. Steven
    Steven avatar
    27 posts
    Member since:
    May 2012

    Posted 22 Apr 2013 Link to this post

    Can someone at Telerik please address this issue?
  3. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 23 Apr 2013 Link to this post

    Hi Steven,

    In general setting attributes on the client side does not persist over a post back of the page and therefore you are not able to get the value of the attribute that you set on the client side from the server side. Please take a look at the end of this help article where it is explained which of the properties that are set on client persist on the server ofter a postback of the page. That is why I would recommend that you set the value of the needed attributes on the server side by using the OnAppointmentContextMenuItemClicked event handler.

    All the best,
    Kate
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  4. Steven
    Steven avatar
    27 posts
    Member since:
    May 2012

    Posted 23 Apr 2013 Link to this post

    I have changed my code to do this now and it's working.  However, the IsLocked attribute sets whether or not an image is visible on the schedule via the appointment template.  After the NEXT postback, the image shows as it should, but I need it to re-evaluate immediately.

    How can I make the appointment template update for that appointment only?  I have a lot of data and I don't want to rebind all of it, just the one that changed.

    Code:
    protected void schMasterScheduler_AppointmentContextMenuItemClicked(object sender, AppointmentContextMenuItemClickedEventArgs e)
    {           
        e.Appointment.Attributes["IsLocked"] = e.Appointment.Attributes["IsLocked"] == bool.TrueString ? bool.FalseString : bool.TrueString;
        getProductionRunById(e.Appointment.ID.ToString()).IsLocked = Convert.ToBoolean(e.Appointment.Attributes["IsLocked"]);
    }

    <AppointmentTemplate>           
         <div class="appointmentTemplate">  
         <%# Eval("Subject") %> | <%# Eval("BatchNumber") %>                 
             <asp:Image id="imgLocked" runat="server" ImageUrl="~/_Layouts/Capgemini.BHI.Webparts/images/lock.png" ToolTip="Locked"  
                 Visible='<%# Convert.ToBoolean(Eval("IsLocked")) %>' CssClass="lock"></asp:Image>                   
         </div>
     </AppointmentTemplate>
  5. Steven
    Steven avatar
    27 posts
    Member since:
    May 2012

    Posted 24 Apr 2013 Link to this post

    Can someone please address this?
  6. Plamen
    Admin
    Plamen avatar
    3079 posts

    Posted 25 Apr 2013 Link to this post

    Hi Steven,

    Thank you for getting back to us.

    You will have to control this appearance by addind a CSS class. Here is the code that I worked at my side:

    <AppointmentTemplate>          
         <div class="appointmentTemplate"
         <%# Eval("Subject") %>               
             <asp:Image id="imgLocked" runat="server" ImageUrl="lock.png" ToolTip="Locked" 
                 Visible='<%# Convert.ToBoolean(Eval("IsLocked")) %>' CssClass="lock"></asp:Image>                  
         </div>
     </AppointmentTemplate>
    protected void RadScheduler1_AppointmentContextMenuItemClicked(object sender, AppointmentContextMenuItemClickedEventArgs e)
       {
           e.Appointment.Attributes["IsLocked"] = e.Appointment.Attributes["IsLocked"] == bool.TrueString ? bool.FalseString : bool.TrueString;
           if (e.Appointment.Attributes["IsLocked"]=="False")
           {
               e.Appointment.CssClass = "hideImage";
           }
           else
           {
               e.Appointment.CssClass = "";
           }
       }
    <style type="text/css">
           .hideImage .lock {
           display:none;
           }
     
       </style>

    Hope this will solve the issue. If you have further question please don't hesitate to contact us again.

    All the best,
    Plamen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top