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

xml provider and attribute

14 Answers 174 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
kyle goodfriend
Top achievements
Rank 2
kyle goodfriend asked on 09 Dec 2008, 06:38 PM
First off, thanks for all your help - I have never worked with a company with the level of assistance you provide - I am a client for life!

I preface that because I feel guilty that I haven't found the answer to this and am sure it is out there.  I want to use the xml provider to minimize the work to build out a scheduler.  I need to include a color, or custom attribute, much like the example you have on the demos site.  Is there a simple example that you could show me so I can take advantage of the included provider AND add a custom attribute?  It appears that this is possible based on what I read in the docs when comparing it to a custom resource, which would require a custom data source.

I see the example at http://demos.telerik.com/aspnet-ajax/Scheduler/Examples/XmlSchedulerProvider/DefaultCS.aspx. 
Questions:
  1. Would I just remove the ondatabound event and set the provider to the xml file in a real world situation?
  2. Is the xml file changed beyond the default for this the attribute to be stored?  I don't see in the example code anywhere that the attribute is defined.

Maybe this is as simple as changing this example a little.  I might not be asking the correct questions.  I just want to give you some background on what I have looked at so you can answer this one time and I hopefully won't bug you again!

14 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 11 Dec 2008, 02:09 PM
Hello Kyle,

Our clients' satisfaction is our finest reward. Feedback such as yours inspire and motivate us. Thank you!

Regarding your question - the good news is that the default XmlSchedulerProvider which comes as part of the Telerik assembly provides support for unlimitted number of custom attributes. In order to utilize this feature you just need to set EnableCustomAttributeEditing  to true and CustomAttributeNames to a list of custom attributes that you need. For example:
CustomAttributeNames ="CustomAttribute, Color, AnotherCustomAttribute ...."

I have prepared a small demo sample which you can use as reference. I have created a MyXmlSchedulerProvider.cs class using the code of the default XmlSchedulerProvider, but effectively I didn't have to change anything in the code since the attributes functionality was already implemented.

Please, feel free to contact us if you have any other questions or concerns.


Best wishes,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
kyle goodfriend
Top achievements
Rank 2
answered on 11 Dec 2008, 05:49 PM
Wonderful.  I thought that was the case since my post.  I think my last question would be the editing function.  I see several examples on customizing that, but is there a way to, without a complete customization of the entire entry, to change the text box to something different?  I am specifically looking to change it to the color combo box.
0
Peter
Telerik team
answered on 12 Dec 2008, 11:44 AM
Hi kyle,

Do you mean the attributes textbox? If so, you can customize its appearance using RadFormDecorator. Simply drag a RadFormDecorator on the page and set its DecoratedControls and Skin properties.

<telerik:RadFormDecorator ID="RadFormDecorator1" DecoratedControls="Textbox" Skin="Vista" runat="server" /> 



All the best,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
kyle goodfriend
Top achievements
Rank 2
answered on 12 Dec 2008, 01:21 PM
Not quite.  I want to replace the text box with a color dropdown box.
0
Peter
Telerik team
answered on 12 Dec 2008, 02:09 PM

You can try the approach from this kb article:
http://www.telerik.com/support/kb/aspnet-ajax/scheduler/how-to-access-controls-in-the-advanced-form.aspx

For a custom attribute named "CustomAttribute", use this code:
 protected void RadScheduler1_FormCreated(object sender, Telerik.Web.UI.SchedulerFormCreatedEventArgs e)  
    {  
        if ((e.Container.Mode == Telerik.Web.UI.SchedulerFormMode.AdvancedEdit) || (e.Container.Mode == Telerik.Web.UI.SchedulerFormMode.AdvancedInsert))  
        {  
            TextBox customAttr = (TextBox)e.Container.FindControl("AttrCustomAttribute");  
            customAttr.Visible = false;  
            RadTextBox customTextbox = new RadTextBox();  
            customTextbox.Text = customTextbox.Text;  
            customAttr.Parent.Controls.Add(customTextbox);  
        }  
    } 

I don't know what you mean by "color dropdown box", so I used RadTextBox instead to illustrate how you can replace the default textbox with any control you like. There is one limitation to this approach - data you enter in the new control will not be persisted after appointment update or insert. If you need two way binding of date you should use this example:
http://demos.telerik.com/aspnet-ajax/Scheduler/Examples/AdvancedFormTemplate/DefaultCS.aspx



Regards,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
kyle goodfriend
Top achievements
Rank 2
answered on 19 Dec 2008, 06:00 PM
As always, fantastic support.  I think I have everything I need working EXCEPT the some formatting issues.  To clarify, I am not using a color dropdown box, but the radControl color picker.  So, I modified what you gave me to this.

            If ((e.Container.Mode = Telerik.Web.UI.SchedulerFormMode.AdvancedEdit) Or (e.Container.Mode = Telerik.Web.UI.SchedulerFormMode.AdvancedInsert)) Then 
                Dim customAttr As TextBox = e.Container.FindControl("AttrcustomColor"
                customAttr.Visible = False 
                Dim customTextBox As RadColorPicker = New RadColorPicker 
                customTextBox.CurrentColorText = customTextBox.CurrentColorText 
                customTextBox.Preset = ColorPreset.Office + ColorPreset.Standard 
                customAttr.Parent.Controls.Add(customTextBox) 
            End If 
  
I get what I think I should get, for the most part.  The only problem is that the number of columns is 1, regardless of what I try.  Although I tried a couple different methods, it seems for me to change the width of the box I had to pass a string, not a number.
                customTextBox.Columns = 5 
                customTextBox.Width = "400" 
 
I see the width changing, but I the number of columns is always 1.  The previous code does go BEFORE the add statement.  Other than this one small detail, I think I am set.  Hopefully this helps somebody else.

Again, Grade A support, I can't thank you enough!






0
Peter
Telerik team
answered on 22 Dec 2008, 03:01 PM
Hi Kyle,

I tried to replicate the problem using your code, but setting the Columns property worked as expected. I can send you a demo project for reference if you think this might help you. As for the width property, usually it can be set like this: customTextbox.Width = Unit.Pixel(400);


All the best,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
kyle goodfriend
Top achievements
Rank 2
answered on 30 Dec 2008, 05:20 PM
I am trying to get this to work, and am stuck on a couple items.  I don't want to have to code everything to get it to work with the data binding.  I will if I have to, and I know it probably isn't that hard once you look at it.  Rather than make it bound, I am adding a colorpicker, and with client side scripts, trying to update the custom attribute box when a color is changed, and set the color of the colorpicker when it loads from the value in the custom attribute text box.  Once I get this to work, I can hide the attribute and I think I will be set.  I still can't get the colorpicker to a width either, but that is probably a CSS thing or something. 

I started with the XmlScheduleProvider example and stripped out the obvious to make it more readable.  Here is the aspx page.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Post171a.aspx.vb" Inherits="Telerik.Web.Examples.Scheduler.XmlSchedulerProviderExample.DefaultVB" %> 
 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart"  %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"
             <script type="text/javascript"
                function HandleColorChange (sender, eventArgs) 
                { 
                    $get("AttrcustomColor").value = sender.get_selectedColor(); 
                    //alert(sender.get_selectedColor()); 
                    //alert(AttrcustomColor.value); 
                } 
                 
                function GetColorPicker () 
                { 
                    return $find("<%= RadColorPicker1.ClientID %>"); 
                } 
                 
                function SetValue() 
                { 
                    var colorPicker = GetColorPicker(); 
                    colorPicker.set_selectedColor($get("RadColorPicker1_Value").value); 
                } 
                             
 
             </script> 
</head> 
<body class="BODY"
    <form id="form1" runat="server"
        <asp:ScriptManager ID="ScriptManager" runat="server"/> 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="RadScheduler1"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="RadScheduler1" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
         
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Transparency="30" BackColor="#E0E0E0" InitialDelayTime="500"
            <asp:Image ID="Image1" Style="margin-top: 200px" runat="server" ImageUrl="~/Ajax/Img/loading.gif" 
                BorderWidth="0px" AlternateText="Loading"></asp:Image> 
        </telerik:RadAjaxLoadingPanel> 
                 
        <telerik:RadScheduler runat="server" ID="RadScheduler1" 
            Width="750px" Skin="WebBlue" EnableEmbeddedSkins="True" TimeZoneOffset="03:00:00" 
            SelectedDate="2007-03-30" DayStartTime="08:00:00" DayEndTime="18:00:00"  
            CustomAttributeNames="customColor" EnableCustomAttributeEditing="true" 
            StartEditingInAdvancedForm="true"  
            SelectedView="MonthView" 
            ShowViewTabs="false" 
            StartInsertingInAdvancedForm="true"    
             OverflowBehavior="Expand" 
             > 
             
        </telerik:RadScheduler> 
 
    </form> 
</body> 
</html> 
 

Here is the code behine vb file
Imports Telerik.Web.UI 
Imports System.Drawing 
 
Namespace Telerik.Web.Examples.Scheduler.XmlSchedulerProviderExample 
    Partial Class DefaultVB 
        Inherits Telerik.QuickStart.XhtmlPage 
 
        Private Const ProviderSessionKey As String = "Telerik.Web.Examples.Scheduler.XmlSchedulerProvider.DefaultVB" 
 
        ' You can safely ignore this method. 
        ' Its purpose is to limit the changes to the underlying data only to the active user session. 
        Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init 
            Dim provider As XmlSchedulerProvider 
 
            If (Session(ProviderSessionKey) Is Nothing OrElse (Not IsPostBack)) Then 
                provider = New XmlSchedulerProvider(Server.MapPath("~/App_Data/Appointments.xml"), False) 
                Session(ProviderSessionKey) = provider 
            Else 
                provider = Session(ProviderSessionKey) 
            End If 
 
            RadScheduler1.Provider = provider 
        End Sub 
 
        Protected Sub RadScheduler1_AppointmentDataBound(ByVal sender As Object, ByVal e As UI.SchedulerEventArgs) Handles RadScheduler1.AppointmentDataBound 
            'ee.Appointment.ToolTip = e.Appointment.Subject & ": " & e.Appointment.Attributes("Description") 
 
        End Sub 
 
        Protected Sub RadScheduler1_FormCreated(ByVal sender As Object, ByVal e As UI.SchedulerFormCreatedEventArgs) Handles RadScheduler1.FormCreated 
 
            If ((e.Container.Mode = Telerik.Web.UI.SchedulerFormMode.AdvancedEdit) Or (e.Container.Mode = Telerik.Web.UI.SchedulerFormMode.AdvancedInsert)) Then 
                Dim customAttr As TextBox = e.Container.FindControl("AttrcustomColor") 
                'customAttr.Visible = False 
                Dim customTextBox As RadColorPicker = New RadColorPicker 
                'customTextBox.CurrentColorText = customAttr.Text 
 
                With customTextBox 
                    .Preset = ColorPreset.Office '+ ColorPreset.Standard 
                    .ShowIcon = False 
                    .PreviewColor = True 
                    .ID = "RadColorPicker1" 
                    .OnClientColorChange = "HandleColorChange" 
                    .OnClientLoaded = "SetValue" 
                    .Width = Unit.Pixel(400) 
                    'AddHandler .ColorChanged, AddressOf RadColorPicker1_ColorChanged 
                End With 
 
                'customTextBox.Columns = 5 
                customAttr.Parent.Controls.Add(customTextBox) 
 
 
            End If 
        End Sub 
 
        Protected Sub RadColorPicker1_ColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadColorPicker1.ColorChanged 
            'Dim customAttr As TextBox = FindControl("AttrcustomColor") 
            'customAttr.Text = ColorTranslator.ToHtml(RadColorPicker1.SelectedColor) 
        End Sub 
    End Class 
End Namespace 

My issue is that I can't find the attribute control to set and get the value with the javascript.  I know the control is in a parent control, but I can't seem to find it.  Hopefully this is an no brainer for you.  If you could point out why theh width of the colorpicker is not working, that would be great.  If not, I will figure it out.  I just think if I could get the javascript to work, this solution would be a lot easier to trouble shoot than the custom controls with the data binding example.  It would be easier to upgrade controls too I think - less custom stuff to hassle with.

The result should:
  1. when it is loaded, take the value from the attribute text box and set the value of the colorpicker
  2. when the colorpicker changes color, set the value of the attribute text box with the value of the colorpicker.

Thanks a ton!

0
Peter
Telerik team
answered on 05 Jan 2009, 04:27 PM

Okay, I see what you are after. Still, it would be too much of a hack to implement this scenario without the use of the advanced templates:
http://demos.telerik.com/aspnet-ajax/Scheduler/Examples/AdvancedFormTemplate/DefaultCS.aspx

I recommend you review this example since it is very useful and grants you unlimitted control and flexibility over the advanced form. You may find it useful for some other scenarios in the future. You can always contact us if you encounter problems or if you have questions about this example. You can download a working sample from here.


Best wishes,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
kyle goodfriend
Top achievements
Rank 2
answered on 05 Jan 2009, 05:27 PM
I have the color selector set when it loads now, but I still need to know how to set the textbox when the color is changed.  I can't find the control in the javascript.  Is that possible to identify for me?  I have played with the example you have identified.  One issue I still have is that if I put a colorpicker in the area where the attributes are, it won't grow in width.  If I put it in the upper portion, it does grow in width.  Could this be a bug?

When I tinkered with the more complicated example, I could not get an attribute value or additional field like the room field.  Is there a way you could provide an example where a color picker was used?  I have tried everything I can think of and it won't work.  IF I could get that to work, I might go that route.  I still think if I could simply set the attribute field text box via javascript, it would be much easier to maintain.
0
Peter
Telerik team
answered on 06 Jan 2009, 03:57 PM

Actually, I just thought of a simpler solution. Please, check the attached demo.


Regards,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
kyle goodfriend
Top achievements
Rank 2
answered on 06 Jan 2009, 06:03 PM
Fantastic.  Does the colorpicker display vertically?  I added this to the demos project from the website and I can't get it to display horizontally.  The colors are stacked on top of each other.

When I put this in a new site, it still shows the colors stacked.  If this is can't be fixed, I would need to add it to the advanced form I think.
0
Accepted
Peter
Telerik team
answered on 09 Jan 2009, 08:29 AM
Hi kyle,

Can you modify the demo project I sent you so that the problem can be observed there and send it back to us via a support ticket?


Regards,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
kyle goodfriend
Top achievements
Rank 2
answered on 09 Jan 2009, 03:11 PM
I upgraded the dll to the newest release and the formatting is now as it should be.  Thanks for the help.
Tags
Scheduler
Asked by
kyle goodfriend
Top achievements
Rank 2
Answers by
Peter
Telerik team
kyle goodfriend
Top achievements
Rank 2
Share this question
or