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

Hiding fields in advanced insert and update

13 Answers 306 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 03 Sep 2008, 02:54 PM
Hi,

All I want to be visible in the advanced forms are the From label and calendar, To label and calendar, my resources drop down, and the insert, and cancel buttons.  Is  there a way to simply make all the other controls not visible without having to create a new template?  Thanks

13 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 03 Sep 2008, 06:21 PM
All I want to do is simply do is to hide two controls.  The description text box and the all day event check box.
0
Peter
Telerik team
answered on 04 Sep 2008, 11:00 AM
Hello Chris,

You can easily hide those two controls in the advanced form with the following code:

protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)  
{  
    if ((e.Container.Mode == SchedulerFormMode.AdvancedEdit) || (e.Container.Mode == SchedulerFormMode.AdvancedInsert))  
    {  
        CheckBox allDayCheckBox = (CheckBox)e.Container.FindControl("AllDayEvent");  
        allDayCheckBox.Visible = false;  
 
        TextBox subjectTextBox = (TextBox)e.Container.FindControl("Subject");  
        subjectTextBox.Visible = false;  
    }  


Kind regards,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Chris
Top achievements
Rank 1
answered on 04 Sep 2008, 12:19 PM
That's great, thanks
0
Chris
Top achievements
Rank 1
answered on 04 Sep 2008, 01:53 PM
OK, one more question.  If all I wanted to do was to add one text box, do I have to redo the Advanced Templates?
0
Peter
Telerik team
answered on 08 Sep 2008, 12:54 PM
Hello Chris,

You can use similar approach and again handle the FormCreated event. Since I am not sure where exactly you want the addtional textbox to appear, I am showing how to add it to both the advanced and basic controls  panels. Furthermore, you can use the AddAt() method instead of just the Add() method to nest the textbox in a specific postion.

 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 txb1 = new TextBox();  
            txb1.Text = "Basic Panel";  
            Panel basicPanel = (Panel)e.Container.FindControl("BasicControlsPanel");  
            basicPanel.Controls.AddAt(0, txb1);  
 
            TextBox txb2 = new TextBox();  
            txb2.Text = "Advanced Panel";  
            Panel advnacedPanel = (Panel)e.Container.FindControl("AdvancedControlsPanel");  
            advnacedPanel.Controls.Add(txb2);  
 
        }  
    } 

Let us know if you have any other questions.



Regards,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Peter
Telerik team
answered on 08 Sep 2008, 02:17 PM
Hi again Chris,

Just a quick note - when using this approach, you need to set EnableViewState="false" to prevent errors caused by postback after the advanced form is displayed.

Greetings,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Chris
Top achievements
Rank 1
answered on 08 Sep 2008, 06:21 PM
OK,

Is there a way I can grab whatever is typed into that text box after I click the Insert or Update button in the template?

EDIT:  Or in the end would it be easier to use a custom template?  If so, I need a template that has all of the existing fields, except that only the start date, end date, and resource drop down are visible.  And then beside that drop down, I need a text box which can hold a number of hours?
0
Peter
Telerik team
answered on 09 Sep 2008, 08:50 AM
Hi Chris,

Perhaps you can use Custom Attributes. If this is not exactly what you need, then you can consider the
Customizing the advanced template example.

Feel free to ask us if you have further questions.


Best wishes,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Chris
Top achievements
Rank 1
answered on 09 Sep 2008, 01:28 PM
Thanks for your help so far, the Custom Attributes work great.  I have one last question.  Is there a way that I can put a selectedindexchanged event or something related on my resource drop down.  I have three options in the drop down.  "Vacation - Half Day", "Vacation - Full Day" and "Training Day".  If they select one of the first two, then the Hours text box should be hidden, if they select Training Day, then it should show the text box.
0
Accepted
Peter
Telerik team
answered on 12 Sep 2008, 02:08 PM
Hi Chris,


The resource DropDownList is defined in ResourceControl.ascx like this:
<asp:DropDownList   runat="server" ID="ResourceValue" /> 

The hours textbox is actually a RadDateInput and is defined in SchedulerDefaultForm.ascx like this:
<li> 
            <label for='<%= StartDate.ClientID %>'><%= Owner.Localization.AdvancedFrom %></label>  
            <telerik:RadDatePicker  runat="server" ID="StartDate" CssClass="rsAdvInput" 
                                    Width="100px" SharedCalendarID="SharedCalendar" 
                                    Skin='<%# Owner.Skin %>' Calendar-Skin='<%# Owner.Skin %>' 
                                    Culture='<%# Owner.Culture %>' 
                                    DateInput-DateFormat='<%# Owner.EditFormDateFormat %>' /> 
            <telerik:RadDateInput   runat="server" ID="StartTime" CssClass="rsAdvInput" 
                                    Width="65px" Skin='<%# Owner.Skin %>' Culture='<%# Owner.Culture %>' 
                                    DateFormat='<%# Owner.EditFormTimeFormat %>' /> 
        </li> 
        <li> 
            <label for='<%= EndDate.ClientID %>'><%= Owner.Localization.AdvancedTo%></label>  
            <telerik:RadDatePicker  runat="server" ID="EndDate" CssClass="rsAdvInput" 
                                    Width="100px" SharedCalendarID="SharedCalendar" 
                                    Skin='<%# Owner.Skin %>' Calendar-Skin='<%# Owner.Skin %>' 
                                    Culture='<%# Owner.Culture %>' 
                                    DateInput-DateFormat='<%# Owner.EditFormDateFormat %>' /> 
            <telerik:RadDateInput   runat="server" ID="EndTime" CssClass="rsAdvInput" 
                                    Width="65px" Skin='<%# Owner.Skin %>' Culture='<%# Owner.Culture %>' 
                                    DateFormat='<%# Owner.EditFormTimeFormat %>' /> 
        </li> 

Since AdvancedForm.ascx uses both ResourceControl and SchedulerDefaultForm you can implement the desired functinality like this:

AdvancedForm.ascx.cs
protected void Page_Load(object sender, EventArgs e)  
        {  
            DropDownList resourceDDL = (DropDownList)ResourceControl1.FindControl("ResourceValue");  
            resourceDDL.SelectedIndexChanged += new EventHandler(resourceDDL_SelectedIndexChanged);  
            resourceDDL.AutoPostBack = true;  
 
            if (Owner.OverflowBehavior == OverflowBehavior.Scroll)  
            {  
                AdvancedEditOptionsPanel.CssClass += " rsScrollingContent";  
            }  
        }  
 
        void resourceDDL_SelectedIndexChanged(object sender, EventArgs e)  
        {  
            RadDateInput startDateInput = (RadDateInput)SchedulerDefaultForm1.FindControl("StartTime");  
            RadDateInput endDateInput = (RadDateInput)SchedulerDefaultForm1.FindControl("EndTime");  
                   
            if ([MyCondition])  
            {  
                startDateInput.Visible = false;  
                endDateInput.Visible = false;  
            }  
            else 
            {  
                startDateInput.Visible = true;  
                endDateInput.Visible = true;  
            }  
              
        } 

Please, try the above suggestion and let us know how it goes.

Cheers,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Chris
Top achievements
Rank 1
answered on 12 Sep 2008, 02:14 PM
Thanks a lot for your help guys.  I ended up creating a custom edit and insert template which was easier than I thought it was going to be.  I stuck the template inside a user control and I just handle the events in that.

My scheduler sets a datasource to a generic list, loads in information based on the current user, applies CSS to the different resources, updates, inserts, and deletes from the database, and has custom templates.  I'm also using customized radCalendar controls in it as well that load in holidays.  Your control is really flexible and I really enjoyed using it.  Thanks
0
Rajeev
Top achievements
Rank 1
answered on 26 Dec 2008, 03:16 PM
Hi All,

I am using following code to hide the controls. I am able to find control and set visibility false. But I am getting javascript error like

"Line: 113
Error: '0.parentNode' is null or not an object " for removing "AllDayEvent" and

"Line: 46
Error: 'style' is null or not an object" for removing "Subject" field.

Am I missing anything?

Also I dont want to show time in selecting Start and End date. I want only date to be allowed for selection but I dont want to show "AllDayEvent".

Any suggestions.

Please reply ASAP.

Thanks,
Rajeev




protected
 void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)  
{  
    if ((e.Container.Mode == SchedulerFormMode.AdvancedEdit) || (e.Container.Mode == SchedulerFormMode.AdvancedInsert))  
    {  
        CheckBox allDayCheckBox = (CheckBox)e.Container.FindControl("AllDayEvent");  
        allDayCheckBox.Visible = false;  
 
        TextBox subjectTextBox = (TextBox)e.Container.FindControl("Subject");  
        subjectTextBox.Visible = false;  
    }  
}
0
Peter
Telerik team
answered on 29 Dec 2008, 11:06 AM
Hi Rajeev,

When you set the Visible property to false for controls in the advanced form, they are not rendered. On the other hand, RadScheduler relies on javascript to find the elements in the advanced form and apply styling to them. When the javascript is executed it searches for specific elements, and when it doesn't find them - you get errors.

One possible workaround is to apply a custom css class to the all-day element and to override the textareaWrapper class for the subject textbox: 

 protected void RadScheduler1_FormCreated(object sender, Telerik.Web.UI.SchedulerFormCreatedEventArgs e)  
    {  
        if ((e.Container.Mode == SchedulerFormMode.AdvancedEdit) || (e.Container.Mode == SchedulerFormMode.AdvancedInsert))  
        {  
            CheckBox allDayCheckBox = (CheckBox)e.Container.FindControl("AllDayEvent");  
            allDayCheckBox.CssClass = "Hide";  
 
            TextBox subjectTextBox = (TextBox)e.Container.FindControl("Subject");  
            subjectTextBox.Height = Unit.Pixel(0);  
 
         }  
    } 


<style type="text/css">  
    .Hide, .textareaWrapper  
    {  
        visibility:hidden !important;  
    }     
    </style> 

This way the elements will still render, but they will be not visible. Note, that if you use display:none instead of visibility:hidden, you will still get errors.


Greetings,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Scheduler
Asked by
Chris
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Peter
Telerik team
Rajeev
Top achievements
Rank 1
Share this question
or