Ads 468x60px

Monday, April 30, 2012

XAF : Add Sequence (Serial) Number into a Report

In order to add sequence or serial number such that 1,2,3,4,...etc into a report in devexpress, you should follow the following steps
  • add a Label into a report

  •  Expand Label Tasks dialog

  •  Set Summary Function to Record Number, and Summary Running to Group

Thursday, April 26, 2012

Top Search Tips

At the end of our internet search workshops, participants are asked to come up with a collective top search tips. These can be search tools, individual web sites or search techniques. This is a compilation of the tips from several workshops over the past year.
  1. It isn't your fault! You run your search a second time in Google and you get a completely different set of results, despite having run the same search a mere 20 minutes before. Or you run a site search in Google but the results come from here, there and everywhere. Or your results bear no resemblance whatsoever to your search strategy. Don't worry - it isn't you. Google results are rarely consistent or reproducible from one moment to the next. If you are having serious difficulties getting any sense out of Google, don't struggle. Try another search engine (http://search.yahoo.co.uk), Live (http://www.live.com/), MSE360 (http://www.mse360.com/), Exalead (http://www.exalead.co.uk/)
     
  2. Google Tip 1 highlighted some of the problems with Google but it can still deliver the goods a lot of the time, and it is still the first port of call for most of us. Make sure, though, that you are using the advanced search features to the full and that you are using the right part of Google, for example News for current headlines, Images, Blogsearch etc.
     
  3. Use the Advanced Search screen. There are lots of goodies to be found on the advanced search screens: options for focusing your search by file format (e.g. xls for data and statistics, ppt for expert presentations, pdf for industry or government reports); site and domain search to limit your search to just one web site or a type of organization (e.g. UK government, US academic); and in Google there is a numeric range search.
     
  4. Google Custom Search Engines (Google CSE) at http://www.google.com/coop/cse/. Ideal for building collections of sites that you regularly search, to create a searchable subject list, or to offer your users a more focused search option.
     
  5. See what Google does with your search string. a) If you use the default search box and Google comes back with odd results, click on Advanced Search to see what it has done with your search terms. b) If you use the Advanced Search screen and fill in the boxes, see how Google formats the search strategy by looking the search box at the top of the results page. By learning the commands and prefixes you can build more specific searches on the default search page.

Monday, April 23, 2012

XAF : Show Reports for Individual Views

The Reports module allows you to design reports for a filtered data source. In some scenarios, you may need to preview a report for a certain object or a set of objects that are not related by a criteria. For example, the Invoice business object(s) should be able to be printed in a specific manner. In this case, a specially designed report should be available for display for a particular set of Invoice objects. For this purpose, use the Inplace Reporting feature provided by the Reports module. This topic demonstrates how to use this feature.

To show selected object(s) in a specified report, the Reports module introduces the ShowInReport Action. This Action represents the SingleChoiceAction class instance. Its items represent so-called inplace reports that are designed for the current View's object type.


Wednesday, April 11, 2012

XAF : Override ListView Default Action

In order to override list view default action, you should do the following
  1. Add view controller to your project [i.e. ListViewActionsController]
  2. make class (ListViewActionsController) inherit from DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController
  3. Override the function.[i.e. ProcessCurrentObject].
The following example present an example for this:

   1:  Imports System
   2:  Imports System.ComponentModel
   3:  Imports System.Collections.Generic
   4:  Imports System.Diagnostics
   5:  Imports System.Text
   6:   
   7:  Imports DevExpress.ExpressApp
   8:  Imports DevExpress.ExpressApp.Actions
   9:  Imports DevExpress.Persistent.Base
  10:   
  11:  Public Class ListViewActionsController Inherits
  12:  DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController
  13:   
  14:      Public Shared usrname As String
  15:      Public Sub New()
  16:          MyBase.New()
  17:   
  18:          'This call is required by the Component Designer.
  19:          InitializeComponent()
  20:          RegisterActions(components)
  21:   
  22:      End Sub
  23:   
  24:      Protected Overrides Sub ProcessCurrentObject(ByVal e As 
               DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs)
  25:          If (e.CurrentObject.GetType.Name = "PhoneHolder" And 
                       View.Id = "CustomHolderListView") Then        
  26:              BillingSystem.Module.sharedMod.currentClickedUsername = 
                                   CType(e.CurrentObject, PhoneHolder).UserName
  27:          End If
  28:   
  29:          MyBase.ProcessCurrentObject(e)
  30:      End Sub
  31:   
  32:  End Class

Thursday, April 5, 2012

XAF : Override DetailedView Action

In order to override detailed view action such as SaveAndClose, you should do the following
  1. Add view controller to your project [i.e. DefaultDetailViewActions]
  2. make class (DefaultDetailViewActions) inherit from WebDetailViewController
  3. Override the function.[i.e. SaveAndClose].
The following example present an example for override SaveAndClose function:

   1:  Imports System
   2:  Imports System.ComponentModel
   3:  Imports System.Collections.Generic
   4:  Imports System.Diagnostics
   5:  Imports System.Text
   6:   
   7:  Imports DevExpress.ExpressApp
   8:  Imports DevExpress.ExpressApp.Actions
   9:  Imports DevExpress.Persistent.Base
  10:   
  11:  Imports DevExpress.ExpressApp.Web.SystemModule
  12:  Public Class DefaultDetailViewActions
  13:      Inherits WebDetailViewController
  14:   
  15:      Public Sub New()
  16:          MyBase.New()
  17:   
  18:          'This call is required by the Component Designer.
  19:          InitializeComponent()
  20:          RegisterActions(components)
  21:   
  22:      End Sub
  23:   
  24:      Protected Overrides Sub SaveAndClose(ByVal args As 
                        DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs)
  25:          If args.CurrentObject.GetType.Name = "Calendar" Then
  26:              autoCalendarEntriesAddition(args)
  27:   
  28:          End If
  29:          MyBase.SaveAndClose(args)
  30:      End Sub

Monday, April 2, 2012

XAF : Replace Dropdown Listbox PropertyEditor With RadioGroup PropertyEditor

In order to change the default property editor from which is DropdownList control to RadioGroup control, first you should add the following file to your project folders [i.e. RadioGroupEnumPropertyEditor.vb]

   1:  Imports System
   2:  Imports System.Collections.Generic
   3:  Imports DevExpress.ExpressApp.Web.Editors
   4:  Imports System.Web.UI.WebControls
   5:  Imports DevExpress.ExpressApp.Utils
   6:  Imports DevExpress.ExpressApp
   7:  Imports DevExpress.ExpressApp.Model
   8:  Imports DevExpress.Web.ASPxEditors
   9:   
  10:  Imports System.ComponentModel
  11:   
  12:  Imports DevExpress.Xpo
  13:  Imports DevExpress.Data.Filtering
  14:   
  15:  Imports DevExpress.Persistent.Base
  16:  Imports DevExpress.Persistent.BaseImpl
  17:  Imports DevExpress.Persistent.Validation
  18:   
  19:  Imports DevExpress.ExpressApp.Editors
  20:   
  21:  <PropertyEditor(GetType(RadioButton), "CustomComboEditor", False)> _
  22:  Public Class CheckboxEnumPropertyEditor
  23:      Inherits WebPropertyEditor
  24:   
  25:      Private enumDescriptor As EnumDescriptor
  26:      Private controlsHash As New Dictionary(Of ASPxRadioButton, Object)()
  27:   
  28:      Public Sub New(ByVal objectType As Type, ByVal info As IModelMemberViewItem)
  29:          MyBase.New(objectType, info)
  30:          Me.enumDescriptor = New EnumDescriptor(MemberInfo.MemberType)
  31:   
  32:      End Sub
  33:   
  34:      Protected Overrides Function CreateEditModeControlCore() As WebControl
  35:          Dim placeHolder As New Panel()
  36:          controlsHash.Clear()
  37:          For Each enumValue As Object In enumDescriptor.Values
  38:              Dim radioButton As New ASPxRadioButton()            
  39:              radioButton.ID = "radioButton_" + enumValue.ToString()
  40:              controlsHash.Add(radioButton, enumValue)
  41:              radioButton.Text = enumDescriptor.GetCaption(enumValue)
  42:              'radioButton.CheckedChanged += New EventHandler(radioButton_CheckedChanged)
  43:              AddHandler radioButton.CheckedChanged, AddressOf radioButton_CheckedChanged
  44:              radioButton.GroupName = PropertyName
  45:              placeHolder.Controls.Add(radioButton)
  46:   

Sunday, April 1, 2012

XAF : Implement One-to-One Relationships

Let's consider a simple example of a One-to-One relationship, when both classes that participate in the relationship have properties with a reference to the instance of their opposite class. It's necessary to write extra code within the property's setter method for each class that participates in the relationship to ensure the relationship's integrity, i.e. when a new object is assigned to a reference property, the reference to the previous object instance should be cleared and the assigned object should reference the current one.

This technique can be implemented as shown in the following code example.

   1:  ' Represents the Building class which refers to the building's owner. 
   2:  Public Class Building : Inherits XPObject
   3:      Dim _owner As Person = Nothing 
   4:      Public Property Owner() As Person
   5:          Get 
   6:              Return _owner
   7:          End Get 
   8:          Set(ByVal Value As Person)
   9:              If _owner Is Value Then 
  10:                  Return 
  11:              End If 
  12:   
  13:              ' Store a reference to the former owner. 
  14:              Dim prevOwner As Person = _owner
  15:              _owner = Value
  16:   
  17:              If IsLoading Then Return 
  18:   
  19:              ' Remove an owner's reference to this building, if exists. 
  20:              If Not (prevOwner Is Nothing) AndAlso prevOwner.House Is Me Then 
  21:                  prevOwner.House = Nothing 
  22:              End If 
  23:   
  24:              ' Specify that the building is a new owner's house. 
  25:              If Not (_owner Is Nothing) Then 
  26:                  _owner.House = Me 
  27:              End If 
  28:   
  29:              OnChanged("Owner")
  30:   
  31:          End Set 
  32:      End Property 
  33:  End Class 
  34: