View Full Version : [CLOSED] How to Get Calendar EventStore.Events Code behind

Apr 03, 2013, 4:45 AM
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="frmCalendar.aspx.vb" Inherits="prjExtNetTest.frmCalendar" %>

<!DOCTYPE html>

<head id="Head1" runat="server">
<title>Calendar - Ext.NET Examples</title>
<link rel="stylesheet" href="../Shared/resources/css/main.css" />

.ext-ie .ext-color-4-ad,
.ext-opera .ext-color-4-ad {
color: #7F0000;
.ext-cal-day-col .ext-color-4,
.ext-dd-drag-proxy .ext-color-4,
.ext-color-4-ad .ext-cal-evm,
.ext-color-4 .ext-cal-picker-icon,
.ext-color-4-x dl,
.ext-color-4-x .ext-cal-evb {
background: #7F0000;
.ext-color-4-x .ext-cal-evb,
.ext-color-4-x dl {
border-color: #7C3939;
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" Namespace="CompanyX" />
<ext:EventStore ID="EventStore1" runat="server"></ext:EventStore>

Title="..." >
Border="false" Height="600">
<CalendarStore ID="CalendarStore1" runat="server">
<ext:CalendarModel CalendarId="1" Title="Home" />
<ext:CalendarModel CalendarId="2" Title="Work" />
<ext:CalendarModel CalendarId="3" Title="School" />
<ext:CalendarModel CalendarId="4" Title="Other" />

<ext:Button ID="btnTestSave" runat="server" Text="Submit">


Imports Ext.Net
Public Class frmCalendar
Inherits System.Web.UI.Page
Private mobjCol As Ext.Net.EventModelCollection
Private Sub frmCalendar_Init(sender As Object, e As EventArgs) Handles Me.Init

End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim objEvtStore As New Ext.Net.EventStore
objEvtStore.ID = "EvtStore1"
CalendarPanel1.EventStore = EventStore1
'CalendarPanel1.Listeners.Move.Handler = "record.commit()"
mobjCol = getLstOfEvt()
If Ext.Net.X.IsAjaxRequest = False Then
End If

Dim objMV = New Ext.Net.MonthView
'objMV.EnableDD = False
'objMV.EnableAddFx = False
'objMV.EnableFx = False

CalendarPanel1.MonthView = objMV

CalendarPanel1.ShowWeekView = False
CalendarPanel1.ShowDayView = False
''CalendarPanel1.Listeners.Handler = "record.commit();";
AddHandler CalendarPanel1.DirectEvents.EventClick.Event, AddressOf dayClick

Dim objPar As New Ext.Net.Parameter
objPar.Mode = ParameterMode.Raw
objPar.Name = "recorddata"
objPar.Value = "Ext.encode(record.data)"
CalendarPanel1.DirectEvents.EventMove.ExtraParams. Clear()
CalendarPanel1.DirectEvents.EventMove.ExtraParams. Add(objPar)
CalendarPanel1.Listeners.EventMove.Handler = "record.commit()"
AddHandler CalendarPanel1.DirectEvents.EventMove.Event, AddressOf EventMove

End Sub
Private Sub EventMove(ByVal sender As Object, e As DirectEventArgs)
Dim strJSON As String = e.ExtraParams("recorddata").ToString
Dim obj As EventModel = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Ext.Net.EventModel)(strJSON)
CalendarPanel1.Listeners.Move.Handler = "record.commit();"

End Sub
Private Sub dayClick(ByVal sender As Object, e As DirectEventArgs)
End Sub

Private Function getLstOfEvt() As Ext.Net.EventModelCollection
Dim objCol As New Ext.Net.EventModelCollection
Dim obj As Ext.Net.EventModel
Dim i As Integer
For i = 1 To 10
obj = New Ext.Net.EventModel
obj.EventId = i + 1000
obj.CalendarId = 1
obj.Title = "Title " & i
obj.StartDate = Now.AddDays(i)
obj.EndDate = Now.AddDays(i)
obj.IsAllDay = True
obj.Notes = "Note " & i
For i = 1 To 10
obj = New Ext.Net.EventModel
obj.EventId = i + 2000
obj.CalendarId = 1
obj.Title = "Title x" & i
obj.StartDate = Now.AddDays(i)
obj.EndDate = Now.AddDays(i)
obj.IsAllDay = True
obj.Notes = "Note " & i
Return objCol
End Function

Private Sub btnTestSave_DirectClick(sender As Object, e As DirectEventArgs) Handles btnTestSave.DirectClick
Debug.Print(CalendarPanel1.EventStore.Events.Count )
End Sub
End Class

When I call CalendarPanel1.EventStore.Events.Count at "btnTestSave.DirectClick" and I got count = 0. how can i retrieve events from calendar?

Apr 03, 2013, 7:01 AM

You don't populate the Events during a DirectEvent.

If Ext.Net.X.IsAjaxRequest = False Then
End If

The IsAxajRequest is true during a DirectEvent.

Apr 03, 2013, 7:38 AM
Is my logic problem? I put load data to eventstore under Page_Load? Every time I move the event and Page_Load Trigger , so that data will reload from the orginal state and I cannot get the final result. could you give me some advise?

Apr 03, 2013, 9:14 AM
Where do you want to save the events to? In a Page's property? Well, a Page's property (non static) is recreated on each request including a DirectEvent. A static Page's property will persist for any user using the application. It is also not an option to store the events.

So, the first thing you need to decide - where you store the events. It might be a database or a Session.

The second question how to save the events.

1. Submitting all the events. See the "Save All Events" button in this example.


2. EventStore is an inheritor of Store. It inherits its syncing mechanism which you can use.

Apr 03, 2013, 10:30 AM
Thanks for your advise, I will store in session when event move.