Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Resource view - Calendar...ItemCreated event (Read 9034 times)
Tomy
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Jul 28th, 2012
Resource view - Calendar...ItemCreated event
Sep 27th, 2012 at 8:15am
Print Post  
Hallo,

In WinForm there is EnableDragCreated = True...
what is i WebForm...?

I want to control  e.Item.StartTime and  e.Item.EndTime after draging on calendar..

Thanks in advance

Tomy
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Resource view - Calendar...ItemCreated event
Reply #1 - Sep 27th, 2012 at 11:18am
Print Post  
Hi,

Currently the EnableDragCreate functionality is not available out-of-the box in WebPlanner, but that behavior can be achieved by handling the SelectionEnd client event and pragmatically creating the item. The below snippet shows one possible way to do that. This code considers if the Calendar is grouped by resource and can be used in Resource view.

Code (Javascript)
Select All
// Handle Calendar.DateMouseUp client event to cache any grouped resource
// for further processing
var resource;
function onDateMouseUp(sender, args) {
    // If the Calendar is grouped by resource, the clicked cell object will contain a reference
    // to its associated resource
    resource = args.get_cell().resource;
}

// Handle Calendar.SelectionEnd client event to create the new item
function onSelectionEnd(sender, args) {
    var startTime = args.get_startTime();
    var endTime = args.get_endTime();
    var groupType = sender.getGroupType();

    // Set up the item with the selection start and end time, and add
    // previously cached resource in case the current view is grouped.
    var item = {
      startTime: startTime,
	endTime: endTime,
	contacts: groupType == 1 ? [resource] : undefined, // grouped resource is Contact
	resources: groupType == 2 ? [resource] : undefined, // grouped resource is Resource
	location: groupType == 3 ? resource : undefined, // grouped resource is Location
	task: groupType == 4 ? resource : undefined // grouped resource is Task
    };

    // Create the item
    sender.createItem(item);
}

// Handle Calendar.FormShow client event to cancel the new item popup form
function onFormShow(sender, args) {
    var form = args.get_form();
    if (form.id == 'NewForm') {
        args.set_cancel(true);
    }
}
 



Regards,
Lyubo
  
Back to top
 
IP Logged
 
Tomy
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Jul 28th, 2012
Re: Resource view - Calendar...ItemCreated event
Reply #2 - Sep 28th, 2012 at 4:45am
Print Post  
Thank you Lyubo, but I still have no success...

Another question:

When I drag mouse over calendar, it comes frame "New appoitment" - this is what I need - BUT

How can I get start time, end time and location after click on "OK" button?

Thanks

Tomy
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Resource view - Calendar...ItemCreated event
Reply #3 - Sep 28th, 2012 at 6:05am
Print Post  
Hi Tomy,

If you need to validate some data, when an item is created interactively, you could handle the ItemCreating client-side event. In the handler you have control over the entered item information. For example, if the user hasn't specified Location, you can supply some fallback value:

Code (HTML)
Select All
<!-- Attach a handler to the ItemCreating client event -->
<MindFusion:Calendar ID="Calendar1" runat="server" Width="400px" Height="300px"
    ItemCreatingScript="onItemCreating" /> 



Code (Javascript)
Select All
function onItemCreating(sender, args) {
    var item = args.get_item();

    // If location is not set, assign some predefined fallback value.
    item.location = item.location || fallbackValue;

    // Perform some other kind of validation; i.e. on item.startTime,
    // item.endTime, etc.
    // ...
} 



I hope this helps,
Lyubo
  
Back to top
 
IP Logged
 
Tomy
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Jul 28th, 2012
Re: Resource view - Calendar...ItemCreated event
Reply #4 - Sep 28th, 2012 at 5:02pm
Print Post  
Hello Lyubo...

I still do some mistakes, bud I don't know where...
When I have New Appointment frame, nothing happends...

There is my code and pictures...

Please help

Best regards

Tomy


Private Sub Calendar_Main_ItemCreated(sender As Object, e As MindFusion.Scheduling.ItemEventArgs) Handles Calendar_Main.ItemCreated
Dim varDatoFrom As Date = Now
Dim varDateTo As Date = Now

e.Item.StartTime = New DateTime(Int(Format(e.Item.StartTime, "yyyy")), _
Int(Format(e.Item.StartTime, "MM")), _
Int(Format(e.Item.StartTime, "dd")), _
14, 0, 0)
e.Item.EndTime = New DateTime(Int(Format(e.Item.EndTime, "yyyy")), _
Int(Format(e.Item.EndTime, "MM")), _
Int(Format(e.Item.EndTime, "dd")), _
12, 0, 0)
varDatoFrom = DateValue(e.Item.StartTime)
varDateTo = DateValue(e.Item.EndTime)
End Sub




<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/SiteAccommodation.Master"
CodeBehind="TravelCalendar.aspx.vb" Inherits="touristsoftCH.TravelCalendar" %>

<%@ Register Assembly="MindFusion.Scheduling.WebForms" Namespace="MindFusion.Scheduling.WebForms"
TagPrefix="MindFusion" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<MindFusion:Calendar ID="Calendar_Main" runat="server" CurrentView="ResourceView"
Height="400px" Theme="Silver" GroupType="GroupByLocations" ItemCreatingScript="onItemCreating">
<ListViewSettings NumberOfCells="10">
</ListViewSettings>
<TimetableSettings>
<Dates>
<MindFusion:TimetableDate Value="2012-09-27"></MindFusion:TimetableDate>
</Dates>
</TimetableSettings>
<ResourceViewSettings VisibleCells="28">
<MainHeaderStyle TextAlignment="MiddleCenter" />
</ResourceViewSettings>
</MindFusion:Calendar>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<script type="text/javascript">
function onItemCreating(sender, args) {
var item = args.get_item();
item.location = item.location || fallbackValue;
}
</script>
</asp:Content>


  

APP.jpg (Attachment deleted)
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Resource view - Calendar...ItemCreated event
Reply #5 - Oct 1st, 2012 at 6:07am
Print Post  
Hi Tomy,

What exactly is not working? Are there any errors displayed in the JavaScript console? Or are there any server-side errors? What happens when you hit the "Save" button on the New Appointment form?

If you need the Calendar to initiate a post back every time the schedule is modified (e.g. an item is created, modified, deleted, etc.), set the AutoPostBack property to true. You can also manually post the Calendar from the client-side by calling the postback method of the JavaScript Calendar class (http://www.mindfusion.eu/onlinehelp/webplanner/index.htm?T_MindFusion_Scheduling...).

Also, I don't see where you assign a value for the fallbackValue variable (used in the onItemCreating handler). If it's not assigned, that could also lead to errors.

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint