| var ModalBox = new function() |
| { |
| this._PreviousParentID = null; |
| this._PreviousContentID = null; |
| this.DisplayAjaxContents = function(id) |
| { |
| this.TakeContent(document.getElementById(id).parentNode.id); |
| }; // DisplayAjaxContents(id) |
| this.TakeContent = function(id) |
| { |
| ModalBox._PreviousContentID = id; |
| ModalBox._PreviousParentID = document.getElementById(id).parentNode.id; |
| var c = ModalBox.GetModalContentObject(); |
| c.appendChild(document.getElementById(id).parentNode.removeChild(document.getElementById(id))); |
| }; // TakeContent(id) |
| this.ReplaceContent = function() |
| { |
| var c = ModalBox.GetModalContentObject(); |
| var pp = document.getElementById(ModalBox._PreviousParentID); |
| pp.appendChild(c.removeChild(document.getElementById(ModalBox._PreviousContentID))); |
| ModalBox._PreviousParentID = null; |
| ModalBox._PreviousContentID = null; |
| }; // ReplaceContent() |
| }; |
| <div>I am currently <asp:HyperLink ID="hlStatus" runat="server" />.</div> |
| <div id="SingleSignInOut_Self_Hidden" style="display: none;"> |
| <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"> |
| <table style="width: 100%;"> |
| <tr> |
| <td style="width: 30%;"><b>Status</b></td> |
| <td style="width: 30%;"><b>Reason</b></td> |
| <td style="width: 40%;"><b>Details</b></td> |
| </tr> |
| <tr> |
| <td> |
| <asp:RadioButtonList ID="rblStatus" runat="server" AutoPostBack="true" OnSelectedIndexChanged="Status_Select"> |
| <asp:ListItem Text=" In" Value="1" /> |
| <asp:ListItem Text=" Out" Value="2" /> |
| <asp:ListItem Text=" Extended" Value="3" /> |
| </asp:RadioButtonList> |
| </td> |
| <td> |
| <asp:RadioButtonList ID="rblReason" runat="server" /> |
| </td> |
| <td> |
| </td> |
| </tr> |
| </table> |
| </telerik:RadAjaxPanel> |
| </div> |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| if (!IsPostBack) { Load_Vars(); } |
| } |
| protected void Load_Vars() |
| { |
| hlStatus.NavigateUrl = "javascript:void(ModalBox.DisplayAjaxContents('" + RadAjaxPanel1.ClientID + "'));"; |
| hlStatus.Text = "signed out"; |
| } |
| protected void Status_Select(object sender, EventArgs e) |
| { |
| } |
page that I use within a window. if I add the FormDecorator to the page, I cannot hit the enter key to force the click event.
Is there something inherent wihin the Office2007 skin that prevents the Enter key on buttons? Or is this something with RadDecorator in general?
I am setting the global skin in the web.config.
Simple page:
<%
@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml" >
<
head runat="server">
<title>Untitled Page</title>
</
head>
<
body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<div id="divMain">
<telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecorationZoneID="divMain" />
<asp:Button ID="Button1" runat="server" Text=".net button" /></div>
</form>
</
body>
</
html>
| <telerik:RadDateTimePicker ID="rdtpAppointments_StartTime" SelectedDate='<%# Bind("StartedOn") %>' runat="server"> |
| <DateInput> |
| <ClientEvents OnValueChanged="OnDateSelected" /> |
| </DateInput> |
| </telerik:RadDateTimePicker> |
| <telerik:RadDateTimePicker ID="rdtpAppointments_EndTime" runat="server" SelectedDate="<%# Bind('EndedOn') %>" /> |
| function OnDateSelected(sender, eventArgs) { |
| var endTimePicker = document.getElementById('<%= AppFormView.FindControl("rdtpAppointments_EndTime").ClientID%>'); ; |
| var newValue = new Date(eventArgs.get_newDate()); |
| var oldValue = new Date(eventArgs.get_oldDate()); |
| var difference = Math.round((newValue - oldValue) / 86400000); |
| var oldDate = new Date(endTimePicker.get_selectedDate()) |
| var newDate = oldDate.setDate(oldDate.getDate()+difference); |
| endTimePicker.set_selectedDate() = newDate; |
| } |
| <telerik:RadGrid ID="RadGrid1" runat="server" Skin="Sunset" AllowSorting="true" ShowFooter="true"> |
| <MasterTableView Width="100%"> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| </MasterTableView> |
| <ClientSettings AllowColumnHide="true"> |
| <Scrolling AllowScroll="true" UseStaticHeaders="true" /> |
| <Resizing AllowColumnResize="true" ClipCellContentOnResize="true" /> |
| </ClientSettings> |
| </telerik:RadGrid> |
| <%@ Control Language="vb" Inherits="Scam.AnnuairePro.Edit" AutoEventWireup="false" |
| Explicit="True" CodeBehind="EditAnnuairePro.ascx.vb" %> |
| <%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %> |
| <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> |
| <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
| <script type="text/javascript"> |
| function RowDblClick(sender, eventArgs) |
| { |
| sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical()); |
| } |
| </script> |
| </telerik:RadCodeBlock> |
| <style type="text/css"> |
| .GridEditRow_Default |
| { |
| background:#cccccc !important; |
| } |
| .GridEditRow_Default a |
| { |
| color:#333333; |
| } |
| </style> |
| <asp:Label runat="server" ID="lblMessage"></asp:Label> |
| <telerik:RadGrid ID="RadGrid1" GridLines="None" ShowStatusBar="True" PageSize="15" |
| AllowPaging="True" AllowSorting="False" runat="server" ShowGroupPanel="True" EnableViewState="True"> |
| <mastertableview autogeneratecolumns="false" commanditemdisplay="TopAndBottom" enablenorecordstemplate="true" |
| allowautomaticinserts="true" editmode="editForms" allowautomaticupdates="true" |
| datakeynames="ItemId" onupdatecommand="RadGrid1_UpdateCommand" onneeddatasource="RadGrid1_NeedDataSource" |
| showstatusbar="true" oninsertcommand="RadGrid1_UpdateCommand" ondeletecommand="RadGrid1_DeleteCommand"> |
| <GroupByExpressions> |
| <telerik:GridGroupByExpression> |
| <SelectFields> |
| <telerik:GridGroupByField FieldAlias="Categorie" FieldName="CategoryID"></telerik:GridGroupByField> |
| </SelectFields> |
| <GroupByFields> |
| <telerik:GridGroupByField FieldName="CategoryID" SortOrder="Ascending"></telerik:GridGroupByField> |
| </GroupByFields> |
| </telerik:GridGroupByExpression> |
| </GroupByExpressions> |
| <Columns> |
| <telerik:GridButtonColumn CommandName="MoveUp" Text="Move Up" UniqueName="MoveUp" ButtonType="ImageButton"> |
| </telerik:GridButtonColumn> |
| <telerik:GridButtonColumn CommandName="MoveDown" Text="Move Down" UniqueName="MoveDown" ButtonType="ImageButton"> |
| </telerik:GridButtonColumn> |
| <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete" /> |
| <telerik:GridEditCommandColumn UpdateText="Update" UniqueName="EditCommandColumn" |
| CancelText="Cancel" EditText="Edit"></telerik:GridEditCommandColumn> |
| <telerik:GridBoundColumn DataField="Titre" HeaderText="Titre" UniqueName="Titre" |
| SortExpression="Titre"> |
| </telerik:GridBoundColumn> |
| <telerik:GridHTMLEditorColumn DataField="Description" HeaderText="Description" UniqueName="Description" |
| SortExpression="Description"> |
| </telerik:GridHTMLEditorColumn > |
| <telerik:GridBoundColumn DataField="Adresse" HeaderText="Adresse" UniqueName="Adresse" |
| SortExpression="Adresse"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Telephone" HeaderText="Telephone" UniqueName="Telephone" |
| SortExpression="Telephone"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="URL" HeaderText="URL" UniqueName="URL" |
| SortExpression="URL"></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Courriel" HeaderText="Courriel" UniqueName="Courriel" |
| SortExpression="Courriel"></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="CategoryID" |
| HeaderText="Categorie" UniqueName="CategoryID" |
| SortExpression="CategoryID"> |
| </telerik:GridBoundColumn> |
| <telerik:GridDropDownColumn UniqueName="CategoriesList" |
| SortExpression="SortOrderInfoID" |
| HeaderText="Categorie" ListTextField="Titre" |
| ListValueField="CategoryID" |
| DataField="CategoryID" |
| visible="false"> |
| </telerik:GridDropDownColumn> |
| <telerik:GridBoundColumn DataField="LastModificationDate" HeaderText="Date de dernière modification" UniqueName="LastModificationDate" |
| SortExpression="LastModificationDate"></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="LastModificationUserID" HeaderText="par" UniqueName="LastModificationUserID" |
| SortExpression="LastModificationUserID"></telerik:GridBoundColumn> |
| </Columns> |
| <EditFormSettings CaptionFormatString="Edition des détails de l'entrée nommée {0}" CaptionDataField="Titre"> |
| <FormTableItemStyle Width="100%" Height="29px"></FormTableItemStyle> |
| <FormTableStyle GridLines="None" CellSpacing="0" CellPadding="2"></FormTableStyle> |
| <FormStyle Width="100%" BackColor="#eef2ea"></FormStyle> |
| <EditColumn ButtonType="ImageButton" /> |
| </EditFormSettings> |
| <NoRecordsTemplate></NoRecordsTemplate> |
| </mastertableview> |
| <clientsettings> |
| <ClientEvents OnRowDblClick="RowDblClick" /> |
| <Resizing |
| AllowColumnResize="True" |
| AllowRowResize = "false" |
| ResizeGridOnColumnResize = "false" |
| ClipCellContentOnResize = "true" |
| EnableRealTimeResize = "true" /> |
| </clientsettings> |
| <pagerstyle mode="NextPrevAndNumeric" /> |
| </telerik:RadGrid> |
| <p> |
| <asp:LinkButton CssClass="CommandButton" ID="cmdCancel" resourcekey="cmdReturn" runat="server" |
| BorderStyle="none" Text="Retour" CausesValidation="False"></asp:LinkButton> |
| </p> |
| ' |
| ' DotNetNuke® - http://www.dotnetnuke.com |
| ' |
| Imports DotNetNuke |
| Imports DotNetNuke.Common |
| Imports DotNetNuke.Services.Exceptions |
| Imports DotNetNuke.Services.Localization |
| Imports DotNetNuke.Entities.Users |
| Imports Telerik.Web.UI |
| Imports Telerik.Web.UI.Editor |
| Imports System.Drawing |
| Namespace MyCompany.MyClass |
| ''' ----------------------------------------------------------------------------- |
| ''' <summary> |
| ''' The EditMyClass class is used to manage content |
| ''' </summary> |
| ''' <remarks> |
| ''' </remarks> |
| ''' <history> |
| ''' </history> |
| ''' ----------------------------------------------------------------------------- |
| Partial Class Edit |
| Inherits Entities.Modules.PortalModuleBase |
| #Region "Private Members" |
| Private ItemId As Integer = Null.NullInteger ' -1 |
| #End Region |
| #Region "Event Handlers" |
| ''' ----------------------------------------------------------------------------- |
| ''' <summary> |
| ''' Page_Load runs when the control is loaded |
| ''' </summary> |
| ''' <remarks> |
| ''' </remarks> |
| ''' <history> |
| ''' </history> |
| ''' ----------------------------------------------------------------------------- |
| Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load |
| Try |
| ' Generates false entries |
| 'Dim objA As New MyClassInfo |
| 'Static RandomNumGen As New System.Random |
| 'objA.Titre = "Test " & RandomNumGen.Next |
| 'objA.Description = "Desc " & RandomNumGen.Next |
| 'APCtl.AddEntry(objA) |
| Me.RadGrid1.DataSource = Me.EmployeesData |
| If Not Me.Page.IsPostBack Then |
| ' Define current texts |
| Me.RadGrid1.MasterTableView.NoRecordsTemplate = New NoRecordsTemplate("lblNoEntry.Text", Me.LocalResourceFile) |
| End If |
| Catch exc As Exception 'Module failed to load |
| ProcessModuleLoadException(Me, exc) |
| End Try |
| End Sub |
| Private Sub RadGrid1_UpdateCommand(ByVal source As System.Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand, RadGrid1.InsertCommand |
| Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem) |
| Dim editMan As GridEditManager = editedItem.EditManager |
| Dim ID As String = Null.NullInteger |
| If Not e.Item.ItemIndex = Null.NullInteger Then |
| ID = (CType(e.Item, GridEditFormItem)).OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ItemId").ToString |
| End If |
| Dim column As GridColumn |
| Dim objAP As New MyClassInfo |
| For Each column In e.Item.OwnerTableView.Columns |
| If TypeOf column Is IGridEditableColumn Then |
| Dim editableCol As IGridEditableColumn = CType(column, IGridEditableColumn) |
| If (editableCol.IsEditable) Then |
| Dim editor As IGridColumnEditor = editMan.GetColumnEditor(editableCol) |
| Dim editorType As String = CType(editor, Object).ToString() |
| Dim editorText As String = "unknown" |
| Dim editorValue As Object = Nothing |
| If (TypeOf editor Is GridHTMLEditorColumnEditor) Then ' The RadEditor |
| editorText = CType(editor, GridHTMLEditorColumnEditor).Editor.Text |
| editorValue = CType(editor, GridHTMLEditorColumnEditor).Editor.Text |
| End If |
| If (TypeOf editor Is GridTextColumnEditor) Then |
| editorText = CType(editor, GridTextColumnEditor).Text |
| editorValue = CType(editor, GridTextColumnEditor).Text |
| End If |
| If (TypeOf editor Is GridBoolColumnEditor) Then |
| editorText = CType(editor, GridBoolColumnEditor).Value.ToString() |
| editorValue = CType(editor, GridBoolColumnEditor).Value |
| End If |
| If (TypeOf editor Is GridDropDownColumnEditor) Then |
| editorText = CType(editor, GridDropDownColumnEditor).SelectedText & "; " & CType(editor, GridDropDownColumnEditor).SelectedValue |
| editorValue = CType(editor, GridDropDownColumnEditor).SelectedValue |
| End If |
| Try |
| If Not ID = "-1" Then |
| Dim changedRows As DataRow() = Me.EmployeesData.Tables("Employees").Select("ItemId = " & editedItem.OwnerTableView.DataKeyValues(editedItem.ItemIndex)("ItemId")) |
| ' Chaque DropDownList effectuant des transformations devra avoir sa transformation |
| If column.UniqueName = "CategoriesList" Then |
| changedRows(0)("CategoryID") = editorValue |
| Else |
| changedRows(0)(column.UniqueName) = editorValue |
| End If |
| Me.EmployeesData.Tables("Employees").AcceptChanges() |
| End If |
| Select Case column.UniqueName |
| Case "ItemId" |
| objAP.ItemId = CType(editorValue, Integer) |
| Case "Titre" |
| objAP.Titre = editorValue |
| Case "Description" ' The RadEditor |
| objAP.Description = editorValue |
| Case "Adresse" |
| objAP.Adresse = editorValue |
| Case "Telephone" |
| objAP.Telephone = editorValue |
| Case "URL" |
| objAP.URL = editorValue |
| Case "Courriel" |
| objAP.Courriel = editorValue |
| Case "CategoriesList" 'Equivalent unique de CategoryID, soit la liste deroulante |
| objAP.CategoryID = CType(editorValue, Integer) |
| End Select |
| Catch ex As Exception |
| SetMessage("<strong>Unable to set value of column '" & column.UniqueName & "'</strong> - " + ex.Message) |
| e.Canceled = True |
| End Try |
| End If |
| End If |
| Next |
| If Not e.Canceled = True Then |
| Dim objAPCtl As New MyClassController |
| ' TimeStamp actualisation |
| objAP.LastModificationDate = Date.Now |
| objAP.LastModificationUserID = Me.UserId |
| If ID = Null.NullInteger.ToString Then |
| ' New entry |
| objAPCtl.AddEntry(objAP) |
| SetMessage("Entree ajoutee") |
| Dim MyEmployeesData As DataSet = New DataSet |
| Dim APCtl As New MyClassController |
| Dim objAPs As New List(Of MyClassInfo) |
| objAPs = APCtl.GetEntries() |
| Dim objC As New CollectionToDataSet(objAPs) |
| ' I convert the collection to Dataset in order to remain comparable with Telerik samples as found in your intranet |
| MyEmployeesData = objC.CreateDataSet |
| ' Define PK on Dataset for .Find() method |
| Dim pk(1) As DataColumn |
| pk(0) = MyEmployeesData.Tables(0).Columns("ItemId") |
| MyEmployeesData.Tables(0).PrimaryKey() = pk |
| Me.EmployeesData = MyEmployeesData |
| ' GiveDataSource() |
| ' Rebind and close edit window |
| ' TODO : Find a way to rebind and close the edit window |
| ' TODO Note : (Seb) The methods given by Telerik on forums and samples doesn't works here (Version 2008..1314 problem ?) |
| Response.Redirect(NavigateURL(Request.QueryString("ctl"), "mid=" & Request.QueryString("mid"))) |
| Else |
| ' Update |
| Dim objAPorigin As New MyClassInfo |
| objAPorigin = objAPCtl.GetEntryByID(ID) |
| ' Here is a list of the columns not displayed in the Grid |
| objAP.ItemId = objAPorigin.ItemId |
| objAP.SortOrderInfoID = objAPorigin.SortOrderInfoID |
| ' Update LastSortOrder when category changes |
| Dim booClearCache As Boolean = False |
| If objAP.CategoryID <> objAPorigin.CategoryID Then |
| objAPCtl.UpdateSortOrder(objAP.SortOrderInfoID, objAPCtl.GetLastSortOrder(Constantes.ItemType.Entree, objAP.CategoryID).SortOrder + 1, objAP.CategoryID) |
| ' booClearCache = True |
| End If |
| objAPCtl.UpdateEntry(objAP) |
| Me.RadGrid1.MasterTableView.ClearEditItems() |
| ' If booClearCache Then |
| ' Enforce update on the grid |
| ' Refresh cat group if needed |
| ' Refresh timeStamp |
| Me.Session.Remove("EmployeesData") |
| Me.RadGrid1.DataSource = Me.EmployeesData |
| Me.RadGrid1.DataBind() |
| 'End If |
| SetMessage("Entry updated") |
| End If |
| End If |
| End Sub |
| Private Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemDataBound |
| If (TypeOf e.Item Is GridEditableItem AndAlso CType(e.Item, GridEditableItem).IsInEditMode) Then |
| Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem) |
| Dim editMan As GridEditManager = editedItem.EditManager |
| Dim editor As GridDropDownColumnEditor = CType(editMan.GetColumnEditor("CategoriesList"), GridDropDownColumnEditor) |
| Dim htmleditor As GridHTMLEditorColumnEditor = CType(editMan.GetColumnEditor("Description"), GridHTMLEditorColumnEditor) |
| Dim objRadE As RadEditor = CType(htmleditor.ContainerControl.Controls(0), RadEditor) |
| objRadE.CssClass = "MyRadEditor" |
| objRadE.AutoResizeHeight = True |
| ' TODO |
| 'objRadE.EditModes = EditModes.All |
| objRadE.EnableResize = False |
| objRadE.ToolbarMode = EditorToolbarMode.ShowOnFocus |
| objRadE.Tools.Clear() |
| Dim main As New EditorToolGroup() |
| objRadE.Tools.Add(main) |
| Dim bold As New EditorTool() |
| bold.Name = "Bold" |
| bold.ShortCut = "CTRL+B" |
| main.Tools.Add(bold) |
| Dim italic As New EditorTool() |
| italic.Name = "Italic" |
| italic.ShortCut = "CTRL+I" |
| main.Tools.Add(italic) |
| Dim underline As New EditorTool() |
| underline.Name = "Underline" |
| underline.ShortCut = "CTRL+U" |
| main.Tools.Add(underline) |
| Dim ID As String = "-1" |
| If Not e.Item.ItemIndex = -1 Then |
| ID = (CType(e.Item, GridEditFormItem)).OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ItemId").ToString |
| End If |
| ' Hides some columns |
| editedItem("CategoryID").Parent.Visible = False |
| editedItem("LastModificationDate").Parent.Visible = False |
| editedItem("LastModificationUserID").Parent.Visible = False |
| ' Modify the list control as per custom conventions |
| Dim objAPCtl As New MyClassController |
| Dim objCats As New List(Of CategoryInfo) |
| Dim objEmptyCat As New CategoryInfo |
| objEmptyCat.CategoryID = 0 |
| objEmptyCat.SortOrderInfoId = -1 |
| objEmptyCat.Titre = "-- Choose --" |
| objCats.Add(objEmptyCat) |
| objCats.AddRange(objAPCtl.GetCategories()) |
| editor.DataTextField = "Titre" |
| editor.DataValueField = "CategoryID" |
| editor.DataSource = objCats |
| Editor.DataBind() |
| If Not ID = -1 Then |
| Dim objPA As New MyClassInfo |
| objPA = objAPCtl.GetEntryByID(ID) |
| 'If Not editedItem("CategoryID") Is Nothing Then |
| ' TODO : (seb) We should be able to get the CategoryId from the context RadGrid but I don't know how asap. |
| editor.SelectedValue = objPA.CategoryID.ToString |
| 'CType(editedItem("CategoryID").Controls(0), TextBox).Text |
| 'End If |
| End If |
| 'And so on |
| ElseIf (TypeOf e.Item Is GridDataItem AndAlso Not e.Item.IsInEditMode) Then |
| Dim item As GridDataItem = e.Item |
| ' Replaces some values of the grid so the user has a better comprehension of the stored data |
| Dim ObjAPCtl As New MyClassController |
| Dim catID As String = item("CategoryID").Text |
| If catID = "-1" Or catID = "0" Or catID = Null.NullString Then |
| ' No category |
| item("CategoryID").Text = "-" |
| Else |
| ' Category given |
| Dim ObjCat As New CategoryInfo |
| ObjCat = ObjAPCtl.GetCategoryByID(CType(catID, Integer)) |
| item("CategoryID").Text = ObjCat.Titre |
| End If |
| ' Crop the Description which could be very long |
| If item("Description").Text.Length >= 100 Then |
| item("Description").Text = item("Description").Text.Substring(0, 100) & "[...]" |
| End If |
| ' Replace the UserID by the display name |
| Dim objUCtl As New UserController |
| item("LastModificationUserID").Text = objUCtl.GetUser(Me.PortalId, CType(item("LastModificationUserID").Text, Integer)).DisplayName |
| ' The date |
| 'item("LastModificationDate").Text = CType(item("LastModificationDate").Text, Date).ToLongDateString & " " & CType(item("LastModificationDate").Text, Date).ToLongTimeString |
| ' The sortOrder |
| CType(item("MoveUp").Controls(0), ImageButton).ImageUrl = ResolveUrl("~/images/action_up.gif") |
| CType(item("MoveDown").Controls(0), ImageButton).ImageUrl = ResolveUrl("~/images/action_down.gif") |
| Dim ID As String = "-1" |
| If Not e.Item.ItemIndex = -1 Then |
| ID = (CType(e.Item, GridDataItem)).OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ItemId").ToString |
| End If |
| ' TODO : Update Telerik.Web.UI and use Drag'n'Drop for Re-ordering |
| Dim LastSortIndex As Integer = ObjAPCtl.GetLastSortOrder(Constantes.ItemType.Entree, catID).SortOrder |
| Dim MySortIndex As Integer = ObjAPCtl.GetSortOrderByID(ObjAPCtl.GetEntryByID(ID).SortOrderInfoID).SortOrder |
| If MySortIndex = LastSortIndex And MySortIndex = 1 Then |
| ' 1 entry only |
| item("MoveUp").Controls(0).Visible = False |
| item("MoveDown").Controls(0).Visible = False |
| ElseIf MySortIndex = LastSortIndex Then |
| ' End of the list |
| item("MoveDown").Controls(0).Visible = False |
| ElseIf MySortIndex = 1 Then |
| ' Start of the list |
| item("MoveUp").Controls(0).Visible = False |
| End If |
| End If |
| End Sub |
| Private Sub RadGrid1_ItemCommand(ByVal source As System.Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand |
| If e.Item.GetType.Equals(GetType(GridDataItem)) Then |
| ' TODO : Update Telerik.Web.UI and use Drag'n'Drop for Re-ordering |
| ' Up/Down for re-ordering |
| Dim item As GridDataItem = CType(e.Item, GridDataItem) |
| Dim ID As String = "-1" |
| If Not e.Item.ItemIndex = -1 Then |
| ID = item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ItemId").ToString |
| End If |
| Dim objAPCtl As New MyClassController |
| Dim objAP As MyClassInfo = objAPCtl.GetEntryByID(ID) |
| If e.CommandName = "MoveUp" Then |
| objAPCtl.UpdateSortOrderByMove(objAP.SortOrderInfoID, Constantes.ItemType.Entree, objAP.CategoryID, True) |
| ElseIf e.CommandName = "MoveDown" Then |
| objAPCtl.UpdateSortOrderByMove(objAP.SortOrderInfoID, Constantes.ItemType.Entree, objAP.CategoryID, False) |
| End If |
| Me.Session.Remove("EmployeesData") |
| Me.RadGrid1.DataSource = Me.EmployeesData |
| Me.RadGrid1.DataBind() |
| End If |
| End Sub |
| Private Sub GiveDataSource() |
| RadGrid1.DataSource = Me.EmployeesData |
| Me.EmployeesData.Tables("Employees").PrimaryKey = New DataColumn() {Me.EmployeesData.Tables("Employees").Columns("ItemId")} |
| End Sub |
| Private Sub RadGrid1_NeedDataSource(ByVal source As System.Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource |
| If Not Me.EmployeesData Is Nothing Then |
| GiveDataSource() |
| Else |
| Me.RadGrid1.DataSource = New List(Of MyClassInfo) |
| End If |
| End Sub |
| Private Sub Page_PreRender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.PreRender |
| If Not MyBase.IsPostBack Then |
| ' Me.RadGrid1.MasterTableView.Items(0).Edit = True |
| Me.RadGrid1.MasterTableView.Rebind() |
| End If |
| End Sub |
| Protected Sub RadGrid1_DeleteCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) Handles RadGrid1.DeleteCommand |
| Dim ID As String = (CType(e.Item, GridDataItem)).OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ItemId").ToString |
| Dim MyEmployeesData As DataSet = New DataSet |
| MyEmployeesData = Me.EmployeesData |
| Dim employeeTable As DataTable = MyEmployeesData.Tables("Employees") |
| If Not (employeeTable.Rows.Find(ID) Is Nothing) Then |
| employeeTable.Rows.Find(ID).Delete() |
| employeeTable.AcceptChanges() |
| End If |
| Me.EmployeesData = MyEmployeesData |
| GiveDataSource() |
| Dim APCtl As New MyClassController |
| APCtl.DeleteEntryById(ID) |
| SetMessage("Entree " & ID & " deleted") |
| End Sub |
| Protected Sub SetMessage(ByVal message As String) |
| RadGrid1.Controls.Add(New LiteralControl(message)) |
| End Sub |
| Public Property EmployeesData() As DataSet |
| Get |
| Dim obj As Object = Me.Session("EmployeesData") |
| If Not obj Is Nothing Then |
| Return CType(obj, DataSet) |
| End If |
| Dim MyEmployeesData As DataSet = New DataSet |
| Dim APCtl As New MyClassController |
| Dim objAPs As New List(Of MyClassInfo) |
| objAPs = APCtl.GetEntries() |
| ' No entries ? |
| If objAPs.Count > 0 Then |
| Dim objC As New CollectionToDataSet(objAPs) |
| ' I convert the collection to Dataset in order to remain comparable with Telerik samples as found in your intranet |
| MyEmployeesData = objC.CreateDataSet |
| ' Define PK on Dataset for .Find() method |
| Dim pk(1) As DataColumn |
| pk(0) = MyEmployeesData.Tables(0).Columns("ItemId") |
| MyEmployeesData.Tables(0).PrimaryKey() = pk |
| Me.Session("EmployeesData") = MyEmployeesData |
| Return MyEmployeesData |
| Else |
| ' No entries . |
| Return Nothing |
| End If |
| End Get |
| Set(ByVal value As DataSet) |
| Me.Session("EmployeesData") = value |
| End Set |
| End Property |
| ''' ----------------------------------------------------------------------------- |
| ''' <summary> |
| ''' cmdCancel_Click runs when the cancel button is clicked |
| ''' </summary> |
| ''' <remarks> |
| ''' </remarks> |
| ''' <history> |
| ''' </history> |
| ''' ----------------------------------------------------------------------------- |
| Private Sub cmdCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdCancel.Click |
| Try |
| Response.Redirect(NavigateURL(), True) |
| Catch exc As Exception 'Module failed to load |
| ProcessModuleLoadException(Me, exc) |
| End Try |
| End Sub |
| #End Region |
| End Class |
| End Namespace |