Calendar Scheduler

1 Answer 50 Views
Scheduler
Al
Top achievements
Rank 1
Al asked on 30 Sep 2024, 03:57 PM

Hi Guys

How to validate the following in the RadScheduler

I have a Webform with the RadScheduler and in the Popup form I the following dropdown list that I would like to be mandatory, user must select an item in order to continue saving the scheduler.

private void getReasons(int pReasonId)
    {
        // Create a new DataTable.        
        DataTable dtReason = new DataTable("scheduler_reasons");
        DataColumn dtColumn;

        // Create id column
        dtColumn = new DataColumn();
        dtColumn.DataType = typeof(Int32);
        dtColumn.ColumnName = "ID";
        dtColumn.Caption = "Reason ID";
        dtColumn.ReadOnly = false;
        dtColumn.Unique = true;
        // Add column to the DataColumnCollection.
        dtReason.Columns.Add(dtColumn);

        // Create Name column.
        dtColumn = new DataColumn();
        dtColumn.DataType = typeof(String);
        dtColumn.ColumnName = "calendar_reason";
        dtColumn.Caption = "Calendar Reason";
        dtColumn.AutoIncrement = false;
        dtColumn.ReadOnly = false;
        dtColumn.Unique = false;
        /// Add column to the DataColumnCollection.
        dtReason.Columns.Add(dtColumn);
                
        // Make id column the primary key column.
        DataColumn[] PrimaryKeyColumns = new DataColumn[1];
        PrimaryKeyColumns[0] = dtReason.Columns["id"];
        dtReason.PrimaryKey = PrimaryKeyColumns;

        // Create a new DataSet
        DataSet dtSet = new DataSet();

        // Add custTable to the DataSet.
        dtSet.Tables.Add(dtReason);

        DataRow workRow = dtReason.NewRow();        
        workRow["ID"] = "1";
        workRow["calendar_reason"] = "Day Off";
        dtReason.Rows.Add(workRow);
        workRow = dtReason.NewRow();        
        workRow["ID"] = "2";
        workRow["calendar_reason"] = "Jury Duty";
        dtReason.Rows.Add(workRow);
        workRow = dtReason.NewRow();        
        workRow["ID"] = "3";
        workRow["calendar_reason"] = "Sick Day";
        dtReason.Rows.Add(workRow);
        workRow = dtReason.NewRow();        
        workRow["ID"] = "4";
        workRow["calendar_reason"] = "Vacation";
        dtReason.Rows.Add(workRow);

        //- Telerik Advanced Edit Form
        Telerik.Web.UI.ResourceType ResReasons = new Telerik.Web.UI.ResourceType("CaleReasons");
        //- Telerik Advanced Edit Form Dropdownlist
        ResReasons.DataSource = dtReason;
        ResReasons.ForeignKeyField = "reasonId";
        ResReasons.KeyField = "ID";
        ResReasons.Name = "Reason";
        ResReasons.TextField = "calendar_reason";
        RadScheduler1.ResourceTypes.Add(ResReasons);

    }

Thank you for your help

Al

1 Answer, 1 is accepted

Sort by
0
Vasko
Telerik team
answered on 03 Oct 2024, 07:51 AM

Hello Al,

Thank you for the provided code snippet.

You can use a RequiredFieldValidator on the DropDownList which is inside the Popup. In our Customizing Advanced Insert and Edit Forms we have an example of a Popup form with a DropDownList, although without the RequiredFieldValidator, however, it can be adjusted with it as well.

Try this approach and see if it helps you out.

Regards,
Vasko
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
Al
Top achievements
Rank 1
commented on 05 Oct 2024, 02:32 PM

Thank you for your reply, I got a little lost, I am using the Telerik Version 2018, could you please provide sample code HOW to

This is my ASPX code How would I add the RequiredFieldValidator to validate the above mentioned 

Telerik.Web.UI.ResourceType
<telerik:RadScheduler ID="RadScheduler1" runat="server" EditFormDateFormat="MM/dd/yyyy" EditFormTimeFormat="hh:mm" EnableRecurrenceSupport="False" 
                      HoursPanelTimeFormat="hh:mm tt" OnAppointmentClick="RadScheduler1_AppointmentClick" OnAppointmentDelete="RadScheduler1_AppointmentDelete" 
                      OnAppointmentInsert="RadScheduler1_AppointmentInsert" OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" 
                      OnAppointmentDataBound="RadScheduler1_AppointmentDataBound" SelectedView="WeekView" 
                      ShowAllDayRow="False" StartInsertingInAdvancedForm="True" EnableCustomAttributeEditing="True" SelectedDate="2019-05-15" Height="600px" 
                      OnNavigationCommand="RadScheduler1_NavigationCommand" Skin="Silk" OnFormCreated="RadScheduler1_FormCreated">
                      <ExportSettings OpenInNewWindow="true">
                           <Pdf PageTopMargin="1in" PageBottomMargin="1in" PageLeftMargin="1in" PageRightMargin="1in"></Pdf>
                      </ExportSettings>                                    
                      <AdvancedForm DateFormat="MM/dd/yyyy" TimeFormat="hh:mm" EnableCustomAttributeEditing="True" Modal="True" />
                      <AppointmentContextMenuSettings EnableDefault="True" />
                      <TimeSlotContextMenuSettings EnableDefault="True" />
             </telerik:RadScheduler>
Al
Top achievements
Rank 1
commented on 05 Oct 2024, 02:36 PM | edited

I looked at the sample provided, and I got lost, the sample code is more like jQuery style I am still on the ASP.NET WebForm version and Telerik old version 2018. Thanks for your help.
Vasko
Telerik team
commented on 10 Oct 2024, 05:33 AM

Hello Al,

The idea is to add the RequiredFieldValidator to the DropDownList, which is located inside the Edit/Inset Popup:

<telerik:RadDropDownList ID="RadDropDownList1" runat="server" Required="true" DefaultMessage="Select an item" AutoPostBack="false">
    <Items>
        <telerik:DropDownListItem Text="Option 1" Value="1" />
        <telerik:DropDownListItem Text="Option 2" Value="2" />
        <telerik:DropDownListItem Text="Option 3" Value="3" />
    </Items>
</telerik:RadDropDownList>

<asp:RequiredFieldValidator ID="rfvDropDownList" runat="server"
    ControlToValidate="RadDropDownList1" ErrorMessage="Please select an option"
    Display="Dynamic" ForeColor="Red" InitialValue="" />

<asp:Button ID="btnSubmit" runat="server" Text="Submit" />

The above code will make sure to return an error message if there is no selected value for the DropDownList. It can be further put inside an Advanced Templte.

Regards,
Vasko
Progress Telerik

Tags
Scheduler
Asked by
Al
Top achievements
Rank 1
Answers by
Vasko
Telerik team
Share this question
or