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

RadScheduler - Using our own custom form

15 Answers 466 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brad
Top achievements
Rank 1
Brad asked on 10 Jan 2011, 01:22 AM
I'm sure this is a simple one.

We are just looking at the RadScheduler's potential to give us a nice and quick Calendar for our application.

Our application is well under way. We have our own Activity table and supporting pages to display add and edit activities.

In a nutshell we don't need the telerik Advanced Edit form. We need it so that clicking an activity shows our add/edit form.

Is this possible? Anyone done this type of thing before? Any tips of potential problems?

Brad

15 Answers, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 10 Jan 2011, 09:06 AM
Hi Brad,

You can use the ShowAdvancedInsertForm() method to show the advanced form on clicking an Activity from the table. Also you need to set the AllowInsert and AllowEdit properties of the RadScheduler to "false" to prevent the opening of the Advanced Form.

Please let me know if you have further questions.

Regards,
Veronica Milcheva
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Brad
Top achievements
Rank 1
answered on 17 Jan 2011, 12:27 AM
Veronica

I'm not sure I understand your response.

"You can use the ShowAdvancedInsertForm() method to show the advanced form on clicking an Activity from the table.'

This is exactly NOT what I want to happen.

I want it so if I click an activity it opens my own popup form. I do not want the AdvancedInsertForm to ever appear. 

So I see I can use AllowInsert and AllowEdit to stop the form, but how do I use the ShowAdvancedInsertForm to show my form, not the standard one?
0
Veronica
Telerik team
answered on 17 Jan 2011, 09:38 AM
Hi Brad,

Please accept my apologies for misleading you.
You can use "External Edit in RadDock" demo as tutorial to show your own advanced form and not the default one.

Please let me know if this was helpful.

All the best,
Veronica Milcheva
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Brad
Top achievements
Rank 1
answered on 18 Jan 2011, 01:45 AM
Veronica

No problem at all. Thanks so much for your help. This looks just like what I am after. I'm having a crack at putting it into my app today.

Thanks again.

Brad
0
Brad
Top achievements
Rank 1
answered on 01 Feb 2011, 12:48 AM
One more question if I may

In our app we have 2 'types' of tasks that the scheduler will be displaying.

One is what we call the standard task. This task is handled by the standard Scheduler Advanced Edit form just fine.

The other type of task is what I'll call here a Special Task. These special tasks have a stack of other parameters and the editing of one of then will require a custom edit form.

My question is, how can I intercept the opening of the advanced edit form to the one appropriate for the type of task being edited?

In pseudo code.

If TaskType == Standard
     Open Standard Edit Form
ELSE
    Open Special Custom Edit Form

Alternativily, I could use the same form, just show and hide parts I need.

Where would I put this code?
0
Veronica
Telerik team
answered on 04 Feb 2011, 09:48 AM
Hi Brad,

You can keep the TaskType of each appointment in custom attribute. If you don't want the user to see the task type of appointments in the advanced form - you can set the property AdvancedForm-EnableCustomAttributeEditing to "false". As for determining whether to open the standart advanced form or the special one you can subscribe to the OnAppointmentDataBound event and use the following code in the handler:

protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
        {
            if (e.Appointment.Attributes["TaskType"] == "Standart")
            {
                RadScheduler1.StartEditingInAdvancedForm = true;
            }
            else
            {
                RadScheduler1.StartEditingInAdvancedForm = false;
            }
        }

Please let me know if this was helpful.

Kind regards,
Veronica Milcheva
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Brad
Top achievements
Rank 1
answered on 07 Feb 2011, 03:22 AM
Veronica

This just about does the trick but I have an issue.

The attributes in e, do not include the value I need to test for.

The select statement that populates the dataset is this

SELECT * FROM [Activity] WHERE act_User_ID = " + User_ID.ToString()

However, the value that i need to test on, which is act_Location_ID is not in the returned set.

So this...

e.Appointment.Attributes["act_Location_ID"]

Returns null. This is despite the fact that every Activity in my db Activity table has an act_Location_ID.

Putting e.Appointment in the watch window shows me all the values it does have. Just that act_Location_ID is not there?


0
Brad
Top achievements
Rank 1
answered on 08 Feb 2011, 12:52 AM
Veronica

The AppointmentDataBound event seems to fire when the scheduler loads as each appointment is added.

What it seems to do is just set the
StartEditingInAdvancedForm
 
attribute as each item is output

So, imagine I have 3 appointments in one day.

The one at 9am is a standard task

The one at 11am is a special task that needs a different edit form

The one at 3pm is a standard task

The code you provided seems to set the
StartEditingInAdvancedForm
 
To true, then false, then true.

On reflection that is not what I need.

What I have found is

 
protected void RadScheduler1_AppointmentClick(object sender, SchedulerEventArgs e)

 
This is more like it. This gets called when you click an appointment.

However, while
StartEditingInAdvancedForm = false
does the job to disable the Advanced Edit form, it instead opens the inline edit form. I don't want that.

What I need is to tell it not to open either of these forms.

Oh, and the Appointment.Attributes still does not have my 'act_Location_ID' in it. But I suspect that has something to do with custom attributes, right? Reading up on that now but any tips would be appreciated.





0
Brad
Top achievements
Rank 1
answered on 09 Feb 2011, 06:09 AM
This is what I have come up with, but it does not work.

protected void RadScheduler1_AppointmentClick(object sender, SchedulerEventArgs e)
   {
       Appointment a = e.Appointment;
  
       if (a.Subject == "Phone Call")
       {
           a.AllowEdit = false;
           String jScript = "showPopUp('AddActivityPopup', 600);";
           ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", jScript, true);
 
       }
       else
       {
           a.AllowEdit = true;
       }
   }

In there you can see my code that opens my own Special Activity form.

The problem with the code above is that it does stop the Rad Advanced Edit form from showing. Not on the first run anyway. It's like by the time this code is executed, the Advanced Edit form it already opening.

If I then close the Advanced Edit form (and my form which opened as expected), and click the task again, it not longer calls this event. Logical, as I just told it to AllowEdit = false. Logical but incorrect.

So, how do I tell the Scheduler to not open either edit form and still call this AppointmentClick event?
0
Veronica
Telerik team
answered on 10 Feb 2011, 08:16 AM
Hi Brad,

Please note that OnAppointmentClick event will fire only when RadScheduler property ReadOnly is set to "true". So when RadScheduler is readonly - you are not allowed to insert or update appointments. Could you please send me your code so I can inspect it and help you?

Thank you!

Best wishes,
Veronica Milcheva
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Brad
Top achievements
Rank 1
answered on 11 Feb 2011, 01:07 AM
Veronica

>>>Please note that OnAppointmentClick event will fire only when RadScheduler property ReadOnly is set to "true"

Why would this fire when ReadOnly is to True? Did you mean False?

I am not setting ReadOnly at all, so I suspect it is False by default. Right?

This is what I have seen so far..

1. If AllowEdit is False, the OnAppointmentClick event does not fire.

2. If AllowEdit is True, the OnAppointmentClick event DOES fire. However, there is nothing you can do in the OnAppointmentClick event to stop the Advanced Edit form from appearing?

This is a show stopper for me using my own Activity edit form. So much so that I have had to change the our functionality to simple redirect the user out of our scheduler page to the page elsewhere on the site where our own Activity Edit form already works.

That I did like this.

protected void RadScheduler1_AppointmentClick(object sender, SchedulerEventArgs e)
      {
          Appointment a = e.Appointment;
 
          int ActivityID = Convert.ToInt32(a.ID);
 
          Activity act = new Activity();
          DataTable dt = act.GetActivityOnActivityID(ActivityID);
 
          DataRow dr = dt.Rows[0];
 
          if (Convert.ToInt32(dr["act_Location_ID"].ToString()) > 0)
          {
              HttpContext.Current.Session["ScheduleActivityID"] = ActivityID;
              int[] aLocationIDs = new int[1];
              aLocationIDs[0] = Convert.ToInt32(dr["act_Location_ID"].ToString());
              HttpContext.Current.Session["aLocationID"] = aLocationIDs;
              HttpContext.Current.Session["CurrentLocationIndex"] = 0;
              Response.Redirect("../Location/LocationViewer.aspx");
          }
      }

Note: In my DB, Activities that have an act_Location_ID of 0 are RadScheduler type tasks. Ones that have an act_Location_ ID > 0 are ones created via my own Location system (Locations have many activities).

What you can see in this code is that I have to open my database to get the Location_ID for this task (activity). As I don't have a solution yet to the problem that the appointment object does not contain all of the values from the SQLDataStore that feeds the data to the appointment. Luckily the ID was there for me to use.

The various session variables in there are used by my LocationViewer page so it knows. . . 

what locations to display (aLocationIDs)
where to start displaying from (CurrentLocationIndex) (it paginates through the Locations)
and the new (ScheduleActivityID) which the LocationViewer page now looks for and opens the Edit form that I have been unable to open from the RadScheduler.

Brad
0
Veronica
Telerik team
answered on 17 Feb 2011, 08:58 AM
Hello Brad,

By default the ReadOnly property of the RadScheduler is "false". However to fire the OnAppointmentClick event - ReadOnly must be set to "true". The reason for that is when ReadOnly is false and on double-clicking on appointment the OnAppointmentEditing event is fired. There is no way to handle both the OnAppointmentClick and OnAppointmentEditing events.

If you still need assistance could you please send me a sample project so I can inspect it and help you?

Kind regards,
Veronica Milcheva
the Telerik team
0
Brad
Top achievements
Rank 1
answered on 12 Sep 2011, 06:44 AM


I finally got this solved!

After posting my original message back in Jan 2011 and not finding a solution, I finally came back to this with fresh eyes and after a heap of Google searches and trial and error found the solution.

Just as a reminder, the problem was that I wanted to use a different edit form depending on the type of activity you edit on the scheduler.

The code that does this trick is this.

protected void RadScheduler1_FormCreating(object sender, SchedulerFormCreatingEventArgs e)
   {
       Appointment a = e.Appointment;
       if (e.Mode == SchedulerFormMode.AdvancedEdit)
       {
           int ActivityID = Convert.ToInt32(a.Attributes["act_Activity_ID"]);
           int LocationID = Convert.ToInt32(a.Attributes["act_Location_ID"]);
 
           if (LocationID > 0)
           {
               e.Cancel = true;
               Session["act_Activity_ID"] = ActivityID;
               Session["loc_Location_ID"] = LocationID;
             
              
              string jScript = "function f(){showEditActivityForm(); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);";
              ScriptManager.RegisterStartupScript(Page, GetType(), "OpenActivityForm", jScript, true);
           }
       }
   }


act_Activity_ID and act_Location_ID are both set as Custom Attributes in the grid properties, like so...

CustomAttributeNames="act_Activity_ID, act_Location_ID"

and showEditActivityForm is a bit of javascript on the page that opens a RadWindow with my edit form.

<script type="text/javascript" language="javascript">
 
    function showEditActivityForm() {
        window.radopen("../Location/AddEditActivity.aspx?m=e", "rwAddActivity");
        return false;
    }
 
</script>
 
 
        <telerik:RadWindowManager ID="rwManager" Behaviors="Close,Move, Resize" ShowContentDuringLoad="false" VisibleStatusbar="false" ReloadOnShow="true" runat="server" Skin="Outlook" EnableShadow="true">
            <Windows>
                <telerik:RadWindow ID="rwAddActivity" Title="Add/Edit Activity" Modal="true" runat="server" Width="800" Height="550" />
            </Windows>
        </telerik:RadWindowManager>

Note that in my case, an Activities LocationID being equal to 0 was my flag that this was a different type of Activity. Your flag could be anything you like. Just make sure you add it to the CustomAttribute set.

Done

Using this method I could have any number of different edit forms.

Such a relief to get this one sussed. I was getting worried that it was not possible.

Brad

Edit: This has been edited as I found an error. If my custom form was called more than once in a row, it would open erroneously when you then opened a standard form. The code above is now correct.)
0
Peter
Telerik team
answered on 14 Sep 2011, 08:11 AM
Hi Brad,

Thank you for sharing your findings in the forum.

If you would like to discuss any other issues, feel free to contact us again.

Best wishes, Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
ProgrammerNet
Top achievements
Rank 1
answered on 22 Apr 2016, 09:57 AM

Thank you for sharing the answer, 

>When using the AdvancedInsertForm how did you proceed to get the form values in the code behind?

 

protected void RadScheduler1_AppointmentCommand(object sender, AppointmentCommandEventArgs e)
        {

if (e.CommandName == "Insert")
            {

//Retrieve form values and save in database.

}

}
           Best regards,

ProgrammerNet

Tags
General Discussions
Asked by
Brad
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Brad
Top achievements
Rank 1
Peter
Telerik team
ProgrammerNet
Top achievements
Rank 1
Share this question
or