DevExpress の ASPxScheduler でのスケジュール移動画面作成(自作)です。
スケジュール移動画面作成(自作)するために下記の7手順が必要になります。
1.スケジュール移動画面作成
2.スケジュール移動画面で親情報(スケジュール)取得
3.スケジュール移動画面情報(項目)を親情報(スケジュール)に紐付設定
4.スケジュール移動画面情報(ボタン)を親情報(スケジュール)に紐付設定
5.親情報(スケジュール)でスケジュール移動画面設定
6.スケジュール移動コマンドクラス作成
7.親情報(スケジュール)でスケジュール移動処理設定
今回は「6」〜「7」までのサンプルを作成します。
※「1」〜「5」は昨日のブログを参照して下さい。
現状の画面デザインはこのようになっています。
↓
<6.スケジュール移動コマンドクラス作成>
・「GotoDateFormCallbackCommand」を継承するクラスを作成します。
【WebForm1.aspx.vb サンプルプログラム(VB.Net)】
1 2 3 4 5 6 7 8 |
Public Class MyGotoDateFormCallbackCommand Inherits GotoDateFormCallbackCommand Public Sub New(ByVal myControl As ASPxScheduler) MyBase.New(myControl) End Sub End Class |
・紐付されたコントロールを検索するメソッドを作成します。
【WebForm1.aspx.vb サンプルプログラム(VB.Net)】
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Private Function FindTemplateControl(ByVal myRootControl As System.Web.UI.Control, ByVal myId As String) As System.Web.UI.Control Dim myControl As System.Web.UI.Control = myRootControl.FindControl(myId) If myControl Is Nothing Then For Each myItem As System.Web.UI.Control In myRootControl.Controls myControl = FindTemplateControl(myItem, myId) If myControl IsNot Nothing Then Exit For End If Next myItem End If Return myControl End Function |
・「Public Overrides Sub Execute(ByVal parameters As String)」のメソッドをオーバレイズさせて作成します。
・スケジュール移動サービスのIFを取得します。
・各項目を上記「FindTemplateControl」メソッドを使用して取得します。
・「GoToDate」メソッドを使用してスケジュール移動を実行させます。
・スケジュール移動画面(ポップアップ)を閉じます。
・後処理として「FinalizeExecute」を実行させます。
【WebForm1.aspx.vb サンプルプログラム(VB.Net)】
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
Public Overrides Sub Execute(ByVal parameters As String) 'ナビゲーター取得 Dim myService As DevExpress.XtraScheduler.Services.IDateTimeNavigationService = Nothing Dim myType As Type = Nothing myType = GetType(DevExpress.XtraScheduler.Services.IDateTimeNavigationService) myService = CType(Control.GetService(myType), DevExpress.XtraScheduler.Services.IDateTimeNavigationService) '移動先取得(日付) Dim myASPxDateEdit As ASPxDateEdit = Nothing Dim myDate As Date = Nothing myASPxDateEdit = CType(FindTemplateControl(Control.Parent, "ASPxDateEdit1"), ASPxDateEdit) myDate = myASPxDateEdit.Value '移動先取得(ビュー) Dim myASPxComboBox As ASPxComboBox = Nothing Dim mySchedulerViewType As SchedulerViewType myASPxComboBox = CType(FindTemplateControl(Control.Parent, "ASPxComboBox1"), ASPxComboBox) mySchedulerViewType = CType(myASPxComboBox.SelectedItem.Value, SchedulerViewType) '移動先設定 myService.GoToDate(myDate, mySchedulerViewType) 'ポップアップクローズ CanCloseForm = True '後処理 FinalizeExecute() End Sub |
<7.親情報(スケジュール)でスケジュール移動処理設定>
・「ASPxScheduler」の「BeforeExecuteCallbackCommand」を作成します。
・コマンドIDでスケジュール移動IDの判断を行います。
・コマンドに上記「MyGotoDateFormCallbackCommand」を設定します。
【WebForm1.aspx.vb サンプルプログラム(VB.Net)】
1 2 3 4 5 6 7 8 |
Private Sub ASPxScheduler1_BeforeExecuteCallbackCommand(sender As Object, e As DevExpress.Web.ASPxScheduler.SchedulerCallbackCommandEventArgs) Handles ASPxScheduler1.BeforeExecuteCallbackCommand 'スケジュール移動 If e.CommandId = SchedulerCallbackCommandId.GotoDateForm Then Dim myASPxScheduler As ASPxScheduler = Nothing myASPxScheduler = CType(sender, ASPxScheduler) e.Command = New MyGotoDateFormCallbackCommand(myASPxScheduler) End If End Sub |
【WebForm1.aspx.vb サンプル全プログラム(VB.Net)】
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
Imports DevExpress.Web Imports DevExpress.Web.ASPxScheduler Imports DevExpress.Web.ASPxScheduler.Internal Imports DevExpress.XtraScheduler Public Class WebForm1 Inherits System.Web.UI.Page Private Sub WebForm1_Init(sender As Object, e As System.EventArgs) Handles Me.Init Dim mySession As DevExpress.Xpo.Session = New DevExpress.Xpo.Session XpoDataSource1.Session = mySession XpoDataSource2.Session = mySession End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Private Sub ASPxScheduler1_BeforeExecuteCallbackCommand(sender As Object, e As DevExpress.Web.ASPxScheduler.SchedulerCallbackCommandEventArgs) Handles ASPxScheduler1.BeforeExecuteCallbackCommand 'スケジュール移動 If e.CommandId = SchedulerCallbackCommandId.GotoDateForm Then Dim myASPxScheduler As ASPxScheduler = Nothing myASPxScheduler = CType(sender, ASPxScheduler) e.Command = New MyGotoDateFormCallbackCommand(myASPxScheduler) End If End Sub End Class Public Class MyGotoDateFormCallbackCommand Inherits GotoDateFormCallbackCommand Public Sub New(ByVal myControl As ASPxScheduler) MyBase.New(myControl) End Sub Public Overrides Sub Execute(ByVal parameters As String) 'ナビゲーター取得 Dim myService As DevExpress.XtraScheduler.Services.IDateTimeNavigationService = Nothing Dim myType As Type = Nothing myType = GetType(DevExpress.XtraScheduler.Services.IDateTimeNavigationService) myService = CType(Control.GetService(myType), DevExpress.XtraScheduler.Services.IDateTimeNavigationService) '移動先取得(日付) Dim myASPxDateEdit As ASPxDateEdit = Nothing Dim myDate As Date = Nothing myASPxDateEdit = CType(FindTemplateControl(Control.Parent, "ASPxDateEdit1"), ASPxDateEdit) myDate = myASPxDateEdit.Value '移動先取得(ビュー) Dim myASPxComboBox As ASPxComboBox = Nothing Dim mySchedulerViewType As SchedulerViewType myASPxComboBox = CType(FindTemplateControl(Control.Parent, "ASPxComboBox1"), ASPxComboBox) mySchedulerViewType = CType(myASPxComboBox.SelectedItem.Value, SchedulerViewType) '移動先設定 myService.GoToDate(myDate, mySchedulerViewType) 'ポップアップクローズ CanCloseForm = True '後処理 FinalizeExecute() End Sub Private Function FindTemplateControl(ByVal myRootControl As System.Web.UI.Control, ByVal myId As String) As System.Web.UI.Control Dim myControl As System.Web.UI.Control = myRootControl.FindControl(myId) If myControl Is Nothing Then For Each myItem As System.Web.UI.Control In myRootControl.Controls myControl = FindTemplateControl(myItem, myId) If myControl IsNot Nothing Then Exit For End If Next myItem End If Return myControl End Function End Class |
それでは、実行して動作確認を行います。
↓
↓
・移動先日付、ビューを変更します。
↓
無事にスケジュールのスケジュール移動画面作成(自作)が出来ました。