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

DataSource for AdvancedForm ResourceControl

6 Answers 129 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 2
Dan asked on 23 Aug 2010, 09:42 PM
I can't seem to figure out how to associate my SQL DataSource to a ResourceControl in a customized advanced form template.  The examples online are not helping to figure this out.  Can you tell me what I'm doing wrong in this code:
<telerik:RadScheduler runat="server" ID="RadScheduler1" Skin="Vista" 
   DataKeyField="ID" DataSubjectField="subject" DataStartField="start" DataEndField="end"
   Height="650px" Width="375px" SelectedView="DayView"
   ShowFooter="true" RowHeight="20px"  ShowViewTabs="false"
   DayStartTime="08:00:00" DayEndTime="17:00:00"                        
   FirstDayOfWeek="Monday" LastDayOfWeek="Sunday"
   EnableDescriptionField="true"
   AppointmentStyleMode="Default"
   EnableResourceEditing="true"
   OnDataBound="RadScheduler1_DataBound"
   OnAppointmentDataBound="RadScheduler1_AppointmentDataBound"
   OnClientFormCreated="schedulerFormCreated"
   OnAppointmentDelete="RadScheduler1_AppointmentDelete"
   OnAppointmentUpdate="RadScheduler1_AppointmentUpdate"
   OnAppointmentInsert="RadScheduler1_AppointmentInsert">
   <AdvancedForm Modal="false" />
   <TimelineView UserSelectable="false" />
   <AppointmentTemplate>
      <div class="rsAptSubject">
         <%# Eval("Subject") %>
      </div>
   </AppointmentTemplate>
   <TimeSlotContextMenuSettings EnableDefault="true" />
   <AppointmentContextMenuSettings EnableDefault="true" />
   <ResourceTypes>
      <telerik:ResourceType KeyField="CPK_CATEGORY" Name="Department" TextField="category" ForeignKeyField="DepartmentID" DataSourceID="dsTodoCategory" />
   </ResourceTypes>
   <AdvancedEditTemplate>
      <scheduler:AdvancedForm runat="server" ID="AdvancedEditForm1" Mode="Edit"
          Subject='<%# Bind("Subject") %>'
          Description='<%# Bind("Description") %>' 
          Start='<%# Bind("Start") %>'
      End='<%# Bind("End") %>'
      RecurrenceRuleText='<%# Bind("RecurrenceRule") %>'
      RoomID='<%# Bind("Room") %>'
      DepartmentID='<% Bind("Department") %>' />
    </AdvancedEditTemplate>
    <AdvancedInsertTemplate>
    <scheduler:AdvancedForm runat="server" ID="AdvancedInsertForm1" Mode="Insert"
    Subject='<%# Bind("Subject") %>'
    Start='<%# Bind("Start") %>'
    End='<%# Bind("End") %>'
    Description='<%# Bind("Description") %>'
    RecurrenceRuleText='<%# Bind("RecurrenceRule") %>'
    RoomID='<%# Bind("Room") %>'
    DepartmentID='<% Bind("Department") %>' />
    </AdvancedInsertTemplate>
</telerik:RadScheduler>
  
In AdvancedForm.ascx:
<asp:Panel runat="server" ID="ResourceControls">
    <ul class="rsResourceControls">
       <li>
          <scheduler:ResourceControl runat="server" ID="ResRoom" Type="Room" Label="Room:" Skin='<%# Owner.Skin %>' />
       </li>
       <li>
          <scheduler:ResourceControl runat="server" ID="ResDepartment" Type="Department" Label="Department:" Skin='<%# Owner.Skin %>' />
       </li>
    </ul>
</asp:Panel>

I get this error when I compile:
Cannot create an object of type 'System.Object' from its string representation '<% Bind("Department") %>' for the 'DepartmentID' property. 

An example of associating a DataSourceID to a custom resource type would be most useful.

Thanks.  Dan

6 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 24 Aug 2010, 04:34 PM
Hi Dan,
 
I am sending you demo of the Advanced Form using SqlDataSource. Let me know if you have more questions or if you need further assistance.


Regards,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dan
Top achievements
Rank 2
answered on 24 Aug 2010, 06:15 PM
Ok, here's what I don't get.  I have a Department field in my appointment data.  So, in my edit form I'm displaying a combo box with a list of departments that comes from DataSourceID dsTodoCategory which I have plugged in as the DataSourceId for the rcbDepartment combo box in AdvancedForm.ascx.  The combo box is now rendering ok in the form.  But, if I'm editing an existing appointment, this combo box is not showing the value of the department in my appointment record even though I have bound the combo box to

Text

 

='<%# Bind("Department") %>'.  Do I have to instead load the combo box selected value from the code behind?

 


So the code is now:
<telerik:RadScheduler runat="server" ID="RadScheduler1" Skin="Vista"
   ... 
   CustomAttributeNames="Department"
   ...
   <AdvancedEditTemplate>
     <scheduler:AdvancedForm runat="server" ID="AdvancedEditForm1"
        Mode="Edit"
        Subject='<%# Bind("Subject") %>'
    Description='<%# Bind("Description") %>' 
    Start='<%# Bind("Start") %>'
    End='<%# Bind("End") %>'
    RecurrenceRuleText='<%# Bind("RecurrenceRule") %>'
    DepartmentID='<% Bind("Department") %>' />
   </AdvancedEditTemplate>
  
form page Page_Load
   sbCommand = new SqlBuilder();
   dsTodoCategory.ConnectionString = sbCommand.GetConnectionString();
   dsTodoCategory.SelectCommand = "SELECT 0 as CPK_CATEGORY, '' as Department union select CPK_CATEGORY, ltrim(rtrim(TEXT_)) as Department FROM CATEGORY WHERE DELFLAG=0 ORDER BY Department";
   dsTodoCategory.SelectCommandType = SqlDataSourceCommandType.Text;
  
AdvancedForm.ascx
<ul class="rsResourceControls">
   <li>
      <span>Department:    </span>
      <telerik:RadComboBox ID="rcbDepartment" runat="server" Skin="Web20"
        DataSourceID="dsTodoCategory" DataTextField="Department"
        DataValueField="CPK_CATEGORY" Text='<%# Bind("Department") %>'>
      </telerik:RadComboBox>
   </li>
</ul>
  
AdvancedForm.ascx.cs
[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
    public string Department
    {
        get
        {
            return rcbDepartment.SelectedValue.Trim();
        }
  
        set
        {
            rcbDepartment.SelectedValue = value;
        }
    }

Thanks for the help,
Dan
0
Peter
Telerik team
answered on 25 Aug 2010, 12:36 PM
Hi Dan,

Please, make sure that your appointment's data table has a DepartmentID field, similar to RoomID, to establish the foreign key relationship. You can see the Database structure topic for reference.

If you continue to experience problems, please open a support ticket, modify our sample as per your scenario and send it back to us for further testing.


All the best,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dan
Top achievements
Rank 2
answered on 25 Aug 2010, 04:35 PM
Peter,
I am having nothing but trouble with trying to custom-code the control.  I'm having javascript errors in IE, but not Firefox (weird).  Can't get the combo box to work.  The save and cancel buttons are not working, etc.  Customizing this control looks to be way too complicated.  I'm stuck with the appointment data from another source so I cannot change it.

So, I am going to use the Scheduler control to simply display the appointments in day view, but exit the control and code my own form for edit/insert of appointments.

Please tell me this.  Is there a way to disable the right-click menu?  If so, how?
Thanks.
Dan
0
Accepted
Peter
Telerik team
answered on 25 Aug 2010, 04:49 PM
Hi Dan,

I will be glad to help you further with customizing the advanced form, but I am not sure how to proceed with this. My assumption was that the best way was to send you a working sample, but now I understand that you have a given data source to work with. We can adapt our scheduler demo to work with a data source you send us.

As an alternative to the advanced form, you can consider External Edit in RadDock.

Both the appointment context menu and the time slot context menu are disabled by default. If you need to disable the context menu for specific time slots, please see this kb article.



All the best,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dan
Top achievements
Rank 2
answered on 25 Aug 2010, 07:05 PM
Thanks Peter.  This one just wasn't working out for me so I'm moving on.

Dan
Tags
Scheduler
Asked by
Dan
Top achievements
Rank 2
Answers by
Peter
Telerik team
Dan
Top achievements
Rank 2
Share this question
or