This is a migrated thread and some comments may be shown as answers.

Programmatically set Resource Type from within AdvancedEdit Template

1 Answer 99 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 19 Jun 2012, 10:32 PM
I'm using the Advanced Form inside of the scheduler with the ResourceControl code pasted from the Telerik demo.

When I set "Type" in the ascx page (my scheduler is in a user control), everything works fine.  However, I need to set the Type programmatically from the C#. 

It appears I should do this in the FormCreating event.  The problem is that I do not know how to access the fields on the AdvancedForm at this point.  I can use FindControl inside of FormCreated, but at that point it is too late to pass Type into the resource control. 

Relevant .ascx code:

This works:
<resource:ResourceControl runat="server" ID="ResVessel" Type="1132" />


<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:RadTextBox runat="server" ID="txtMaterialNumber" CssClass="textbox" Text='<%# Bind("Subject") %>'></telerik:RadTextBox>
                            <br />
 
                            <label>Batch #</label>
                            <telerik:RadTextBox runat="server" ID="txtBatchNumber" CssClass="textbox" ></telerik:RadTextBox>                           
                             
                            <label>Vessel</label
                            <!-- Resource controls should follow the convention Res[Resource Name] for ID -->
                            <resource:ResourceControl runat="server" ID="ResVessel" />
                        </div>
                        <div class="required-right">
                            <label>Start Date</label>
                            <telerik:RadDateTimePicker runat="server" ID="dtpStartDateTime" SelectedDate='<%# Bind("Start") %>'                            
                                TimeView-RenderDirection="Vertical" ShowAnimation-Type="Slide" ShowPopupOnFocus="true" TimeView-Columns="4"
                                TimeView-TimeFormat="H:00" Width="160px" DateInput-DisplayDateFormat="M/d/yyyy - H:00">
                            </telerik:RadDateTimePicker>
                            <br />
 
                            <label>Complete Date</label>
                            <telerik:RadDateTimePicker runat="server" ID="dtpEndDateTime" SelectedDate='<%# Bind("End") %>'
                                TimeView-RenderDirection="Vertical" ShowAnimation-Type="Slide" ShowPopupOnFocus="true" TimeView-Columns="4"
                                TimeView-TimeFormat="H:00" Width="160px" DateInput-DisplayDateFormat="M/d/yyyy - H:00">
                            </telerik:RadDateTimePicker>
                            <br />                          
 
                        </div>
                    </div>
             
                    <div class="popUpDiv">
                        <h4>Optional</h4>
                        <br />
 
                        <div class="optional-left">
                            <label>Ship Date</label>
                            <telerik:RadDatePicker runat="server" ID="calShippingDate" Width="185px"
                                ShowAnimation-Type="Slide" DateInput-DisplayDateFormat="M/d/yyyy" ShowPopupOnFocus="true">
                            </telerik:RadDatePicker>         
                            <br />
 
                            <label>Priority</label>
                            <telerik:RadComboBox runat="server" ID="ddlPriority" CssClass="dropdownlist">
                                <Items>
                                    <telerik:RadComboBoxItem Text="Choose Priority" />
                                </Items>
                            </telerik:RadComboBox>
                            <br />
 
                            <label>Batch Size</label>
                            <telerik:RadTextBox runat="server" ID="txtBatchSize" CssClass="textbox"></telerik:RadTextBox>
                            <br />
                                              
                            <label>Wash Prep</label>
                            <telerik:RadTextBox runat="server" ID="txtWashPrep" CssClass="textbox"></telerik:RadTextBox>
                            <br />
 
                            <label id="raw-material-dep">Raw Material Dependency</label>
                            <telerik:RadTextBox runat="server" ID="txtRawMaterialDependency" CssClass="textbox"></telerik:RadTextBox>
                        </div>
 
                        <div class="optional-right">
                            <label id="top-align">Comments</label>
                            <telerik:RadTextBox runat="server" ID="txtComments" CssClass="textbox-multiline" Rows="7" TextMode="MultiLine" Width="200px"></telerik:RadTextBox>
                        </div>           
                    </div>
 
                    <asp:Panel runat="server" ID="Panel1" 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>

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 22 Jun 2012, 10:28 AM
Hello Steven,

This is a very peculiar scenario. If your advanced form will have only one resource type, then the simplest solution is to just edit the ResourceControl like this:
[Bindable(BindableSupport.Yes, BindingDirection.OneWay)]
   public string Type
   {
       get
       {
           return Owner.ResourceTypes[0].Name;
       }
 
       set
       {
           _type = Owner.ResourceTypes[0].Name;
       }
   }

This hard-codes the Type property to use the first resource type from the RadScheduler's resource types collection so that there is no need to set it explicitly neither in the markup of the advanced form nor in any of the event handlers for RadScheduler.

Would that work well for your case?



Greetings,
Peter
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.
Tags
Scheduler
Asked by
Steven
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or