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

Setting, RadScheduler ResourceHeaderTemplate in code

1 Answer 79 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Arvind
Top achievements
Rank 1
Arvind asked on 13 Jun 2012, 04:41 PM
Hi,

I need to create a rasScheduler dynamically from code, I need to change the header template is it possible to replicate the below snippet in code and assign it to the scheduler dynamically.


<ResourceHeaderTemplate>
    <asp:Panel ID="ResourceWrapper" runat="server">
        <asp:Label ID="AgentLabel" runat="server" Text='<%# Eval("Text") %>' />
    </asp:Panel>
</ResourceHeaderTemplate>

Thanks

Arvind

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 18 Jun 2012, 08:28 AM
Hello Arvind,

Please, try the following code and let me know if you have further questions:

public partial class RadSchedulerWebForm1 : System.Web.UI.Page
{
 
    protected void Page_Load(object sender, EventArgs e)
    {
        RadScheduler1.ResourceHeaderTemplate = new ResourceHeaderTemplate();
    }
 
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        RadScheduler1.Provider = new XmlSchedulerProvider(Server.MapPath("~/App_Data/Appointments.xml"), true);
         
    }
 
}
public class ResourceHeaderTemplate : ITemplate
{
    public void InstantiateIn(Control container)
    {
        Label textLabel = new Label();
        textLabel.ID = "AgentLabel";
        textLabel.DataBinding += new EventHandler(textLabel_DataBinding);
         
        Panel resourceWrapper = new Panel();
        resourceWrapper.ID = "ResourceWrapper";
 
        resourceWrapper.Controls.Add(textLabel);
        container.Controls.Add(resourceWrapper);
    }
 
    void textLabel_DataBinding(object sender, EventArgs e)
    {
        Label resourceText = (Label)sender;
        resourceText.Text = ((SchedulerResourceContainer)resourceText.Parent.Parent).Resource.Text;       
    }   
}


Kind regards,
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
Arvind
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or