Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all 7205 articles
Browse latest View live

How to Customize Export Options of the Printing System in WinForms

$
0
0

This example demonstrates how to access and customize the PrintingSystem object, which is responsible for the print preview and export settings. In order to do this, the PrintingSettingsLoaded and CustomShowPreview events of the PrintingController and WinReportServiceController are handled respectively. Refer to the How to: Customize Export Options of the Printing System topic for details.

IMPORTANT NOTE
You can also customize some print preview settings via the corresponding properties of the report object in the report end-user designer. Refer to the XtraReport Members help topic for more details.

See Also:
How to: Implement a Custom Report Class


How to access the master DetailView information from a nested ListView Controller

$
0
0

This example shows how retrieve master detail view information from the controller for the nested list view. In particular, here we need to know the ID of the parent detail view to adjust our logic in the controller respectively.
There are MasterDetailViewControllerBase and NestedListViewControllerBase controllers that allow you to achieve this task. Your should inherit your controllers for nested list views from the last base controller, if you want to have a MasterDetailViewId for them.
In this instance, the MasterDetailViewControllerBase will provide the required parent view ID for it.

See Also:

How to: Access the Master Object from the Nested List View
Platform Independent way to determine Parent DetailView
FAQ: How to traverse and customize XAF View items and their underlying controls (describes an alternative approach with a Controller for the master DetailView that accesses its nested ListPropertyEditor)

How to access the grid control when a List View's MasterDetailMode attribute is set to ListViewAndDetailView

$
0
0

You might write the following code within your ViewController:

[C#]
(GridControl)View.Control
[VB.NET]
CType(View.Control, GridControl)

and it might work in certain cases when your List View showed only one grid control, i.e. the MasterDetailMode = ListViewOnly. This code is not reliable and may fail if a List View was displayed alongside a Detail View or in other scenarios.
This example shows how to fix this problem and write the correct code for both cases:

[VB.NET]
using System;using DevExpress.XtraGrid;using DevExpress.XtraLayout;using DevExpress.ExpressApp;using DevExpress.XtraGrid.Views.Grid;using DevExpress.ExpressApp.Win.Layout;using DevExpress.ExpressApp.Win.Editors;namespace YourSolutionName.Module.Win {publicclass GridListViewController : ViewController {public GridListViewController() { TargetViewType = ViewType.ListView; }protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); ListView lv = ((ListView)View); //This code works for both the ListViewOnly and ListViewAndDetailView option. GridListEditor listEditor = lv.Editor as GridListEditor;if (listEditor != null) { GridControl grid = listEditor.Grid; GridView gv = listEditor.GridView; //Do something great here. } //The code below works only for the ListViewAndDetailView option. DetailView dv = lv.EditView;if (dv != null) { WinLayoutManager layoutManager = dv.LayoutManager as WinLayoutManager;if (layoutManager != null) { LayoutControl layout = layoutManager.Container; //Do something great here. } } } } }Imports Microsoft.VisualBasicImports SystemImports DevExpress.XtraGridImports DevExpress.XtraLayoutImports DevExpress.ExpressAppImports DevExpress.XtraGrid.Views.GridImports DevExpress.ExpressApp.Win.LayoutImports DevExpress.ExpressApp.Win.EditorsNamespace YourSolutionName.Module.WinPublicClass GridListViewControllerInherits ViewControllerPublicSubNew() TargetViewType = ViewType.ListViewEndSubProtectedOverridesOverloadsSub OnViewControlsCreated()MyBase.OnViewControlsCreated()Dim lv As ListView = (CType(View, ListView))'This code works for both the ListViewOnly and ListViewAndDetailView options.Dim listEditor As GridListEditor = TryCast(lv.Editor, GridListEditor)If listEditor IsNot NothingThenDim grid As GridControl = listEditor.GridDim gv As GridView = listEditor.GridView'Do something great here.EndIf'The code below works only for the ListViewAndDetailView option.Dim dv As DetailView = lv.EditViewIf dv IsNot NothingThenDim layoutManager As WinLayoutManager = TryCast(dv.LayoutManager, WinLayoutManager)If layoutManager IsNot NothingThenDim layout As LayoutControl = layoutManager.Container'Do something great here.EndIfEndIfEndSubEndClassEndNamespace

The best practice is always to access the List View's control via the corresponding ListEditor properties. The same thing is for Detail View - you should access the Detail View's control via the corresponding LayoutManager properties.

See Also:
Access Grid Control Properties
View Items Layout Customization
How to access a tab control in a Detail View layout
FAQ: How to traverse and customize XAF View items and their underlying controls

How to create BarManager, BarAndDockingController and related class descendants

$
0
0

These examples demonstrate how to create descendants of the BarManager, and other classes that are needed for its infrastructure. Here, the following custom classes are implemented:
- MyBarManager
- MySkinBarManagerPaintStyle
- MyBarAndDockingController
- MyBarButtonItem

They can be used at design time as well. To demonstrate this, here is a form where bars and popup menus use our custom bar manager.

See Also:
A custom toolbar button with Checked and DropDown styles

How to copy custom Event class fields when dragging appointments in the Scheduler Control

$
0
0

If you extended the default DevExpress.Persistent.BaseImpl.Event class or implemented your own class, supporting the DevExpress.Persistent.Base.IEvent interface, then you may face the situation when custom fields added to your class won't be copied when copying appointments in the scheduler control. To make it possible, you should manually map your custom data fields to appropriate appointment fields. The How to: Create a Custom Field for an Appointment help topic provides more information on how to do this.
In this example, we have a descendant of the Event class that has two properties with the RuleRequiredFieldAttribute. After adding custom field mappings to the controllers, if we drag and drop an existing appointment in the scheduler control with the Control key pressed, we won't receive a validation exception because custom fields will be correctly copied.
However, adding custom field mappings won't help if we have collection properties, for example, an associated details collection. In this situation, you should handle copying of appointments yourself. The scheduler control provides corresponding API for this. For example, check the SchedulerControl.AllowAppointmentCopy Event help topic for more information.

See Also:
Scheduler Module Overview
How to create fully custom Role, User, Event, Resource classes for use with the Security and Scheduler modules
Scheduler - Provide a way to copy a collection of custom fields when an appointment is being copied

Question Comments

Added By: Lleonard del Río at: 7/16/2014 12:35:02 PM    

I had this code in my solution in v2013 and after upgrading to v2014 it stopped working. I have tried to remove the ! after the reference fields mapping and it seems to work correctly now. Should this code be updated for v2014? Thanks in advance.

Added By: Dennis (DevExpress Support) at: 7/17/2014 12:28:27 AM    

@Lleonard: Thank you for your feedback. We need some additional time to research this behavior. Please bear with us.

In the meantime, you can use the solution that works fine for you.

How to use WorkflowInstanceStore to keep the state in more than a dozen of popular RDBMS

$
0
0

This example is based on the How to: Configure Persistence with WorkflowServiceHost and How to: Enable SQL Persistence for Workflows and Workflow Services help articles from MSDN.

The only difference is that in code you can use the DevExpress.Workflow.Store.WorkflowInstanceStoreBehavior class (it is a part of the DevExpress.Workflow.Activities library) instead of the standard SqlWorkflowInstanceStoreBehavior one.

If you want to enable persistence for self-hosted workflows that use WorkflowApplication programmatically by using the SqlWorkflowInstanceStore class, you can use the built-in DevExpress.Workflow.Store.WorkflowInstanceStore one (it is also a part of the DevExpress.Workflow.Activities library):

[C#]
...usingDevExpress.Workflow.Xpo;usingDevExpress.ExpressApp.Xpo;usingDevExpress.Workflow.Store;...WorkflowInstanceStoredxWorkflowInstanceStore=newWorkflowInstanceStore(typeof(XpoWorkflowInstance),typeof(XpoInstanceKey),newXPObjectSpaceProvider(yourDatabaseConnectionString,null));

If you configure it via the configuration file, use the DevExpressWorkflowInstanceStore element instead of the standard sqlWorkflowInstanceStore one.


Refer to the XAF Workflow persistence storage blog post for more information.

See also:
How to create a correct connection string for XPO providers?
eXpressApp Framework > Concepts > Extra Modules > Workflow Module

How to control the grid column header height by setting the number of text lines

How to suppress the save confirmation when closing a new unmodified object DetailView

$
0
0

Scenario
This example demonstrates how to implement the following behavior (which is default in Microsoft Outlook) in XAF Windows Forms applications:

- A user can create a new record, and when its detail form is opened he or she may close the form without entering any data (e.g., a new record was created by accident). In this case, the form can be closed without any save confirmation, because no user data needs to be saved.

- If a user enters some data into the form and then closes it, the save confirmation appears as expected not to lose entered data.
To test it, run functional tests from the E2114.EasyTests\E2114.ets folder.

 

Steps to implement
Copy the WinSolution.Module.Win\SuppressConfirmationForNewObjectsDetailViewController.xx file into YourSolutionName.Module.Win project.


Your feedback is needed!
We are hesitating to include the current implementation by default, because there are many ways to instantiate new objects in Views and it many cases it is difficult to uniquely state that an object is "untouched". For instance, you may have custom initialization code in the AfterConstruction or OnActivated methods of your business class or Controller, in the ObjectCreating, CustomCloneObject, ActionBase's Execute or other event handlers of standard and custom XAF UI entities.
You and other readers can help us decide faster if you share your thoughts on whether this logic should cover any internal programmatic changes to objects (including Actions!) or should only consider a user touching data editors by hand. Thanks in advance. 

See Also:
WinModificationsController Class
ModificationsController.ModificationsHandlingMode
Core - Disable the confirmation dialog when closing a form with a new object left untouched

Question Comments

Added By: rushdan . at: 12/4/2014 2:08:46 AM    

I have see example . That is great.
So I would like to ask, is it possible to apply for Web ?

Thanks

Added By: Dennis (DevExpress Support) at: 12/4/2014 2:40:43 AM    @rushdan: This solution cannot be applied to the Web version because there are no such confirmation dialogs there by default.Added By: Paul Kubb at: 3/31/2016 9:04:33 PM    Just a little comment that I think this feature should be out-of-the-box.
Popping out this message every time even nothing touched is annoying and I don't think anybody will like it.Added By: Dennis (DevExpress Support) at: 4/1/2016 2:19:57 AM    @Paul: Our team will take your feedback into account, thanks.Added By: Alex Miller at: 4/1/2016 4:22:05 AM    I totally agree with Paul.
@Dennis Please +1 :) Added By: Dennis (DevExpress Support) at: 4/1/2016 6:10:00 AM    OK, thanksAdded By: Willem de Vries at: 1/4/2018 1:05:00 AM    What if this was default behavior?Added By: Dennis (DevExpress Support) at: 1/4/2018 3:47:51 AM    

@Willem: Thank you for your suggestion and please let us know whether this simple solution meets your business needs.
We are hesitating to include the current implementation by default, because there are many ways to instantiate new objects in Views and it many cases it is difficult to uniquely state that an object is "untouched". For instance, you may have custom initialization code in the AfterConstruction or OnActivated methods of your business class or Controller, in the ObjectCreating, CustomCloneObject, ActionBase's Execute or other event handlers of standard and custom XAF UI entities.

You and other readers can help us decide faster if you share your thoughts on whether this logic should cover any internal programmatic changes to objects (including Actions!) or should only consider a user touching data editors by hand. Thanks in advance.

Added By: Willem de Vries at: 1/4/2018 7:11:39 AM    Hi Dennis,

I understand your hesitations and want to withdraw my earliers suggestion.

You could leave it to the developer by introducing a class decorator [SuppressConfirmationForNewObjects] or something alike. That way the developer can apply this logic by choice and on a much more precise scale.

Willem Added By: Dennis (DevExpress Support) at: 1/4/2018 8:25:15 AM    

Thanks for your update, Willem - we will take your idea into account and continue monitoring user requirements in this regard. Right away, you can code such a custom attribute along with a Controller looking at it. Here are additional documentation links that should help you enhance the original example further:
Concepts > Business Model Design > Types Info Subsystem > Access Business Object's Metadata
Extend and Customize the Application Model in Code
https://docs.microsoft.com/en-us/dotnet/standard/attributes/writing-custom-attributes


How to add an unbound column to GridListEditor to execute a custom action for a record

$
0
0

This example shows how to add a custom unbound column to the GridControl in ListView. In the example, a button will be shown in this custom column. When a button is clicked, a custom business action will be executed on the selected record. To be more precise, the boolean Active property of the Order business class will be reversed.
To accomplish this task, we will declare a public SimpleBusinessAction method within the Order class. This will allow to reverse the Active property because for demo purposes it won't have a public setter allowing to set this property directly.
To add a custom unbound column to the GridControl, we will create a new column and configure its editor as needed. To learn more about the GridControl's customizations please refer to the XtraGrid's documentation.

Take special note that XAF Web applications support this scenario out-of-the-box. You can make a method within your business class and mark it with the ActionAttribute. Then, XAF will produce an Action column in the List View for your business class. Refer to the documentation for more details.

IMPORTANT NOTES
One of the prerequisites for this particular solution and the DataAccessMode = Server mode is to have a valid IModelMember defined in the Application Model. You can do this via the Model Editor as described in the eXpressApp Framework > Concepts > Business Model Design > Types Info Subsystem > Customize Business Object's Metadata article.

See Also:
How to provide an inline Action shown right within the ListView control row on the Web
Access Grid Control Properties
Assigning Editors to Individual Cells
Repositories and Repository Items
ActionAttribute Class

Question Comments

Added By: Salam at: 11/27/2012 10:31:29 PM    

Hello Devexpress,
                How to apply the same in Web application?

Added By: Apostolis Bekiaris (DevExpress) at: 1/4/2013 4:00:06 PM    

See also this post http://community.devexpress.com/blogs/eaf/archive/2011/09/16/expandframework-supporting-unbound-columns.aspx

How to use a custom Lookup Property Editor control for reference properties in WinForms

$
0
0

See the How to work with referenced properties via a simple drop down list instead of the standard LookupPropertyEditor KB article for more information.

Question Comments

Added By: Carlitos at: 8/18/2012 7:29:01 AM    

I'm not able to see K18169. When I try it says: You can't view this question because it is marked as private.

Added By: Gustavo Marzioni at: 8/27/2012 2:45:42 PM    

it doesn't work when you create several hundred of Demolookup objects

Added By: Hurzi! at: 9/11/2012 10:30:56 PM    

K18169 is still marked as private...

Added By: Jeffrey E at: 12/13/2015 3:50:53 AM    

Hi Support,

I tried this example, but I noticed that when I input in the lookupedit for instance I input letter P, instead letter N appeared. Please see the screenshot - http://screencast-o-matic.com/watch/colIXChv40. I want to make the lookupedit a search text, I removed the arrow button then autofilter.

Thanks.

Added By: Dennis (DevExpress Support) at: 12/14/2015 4:59:41 AM    

@Jeffrey: To process your recent post more efficiently, I created a separate ticket on your behalf: T324200: E1101 auto-filter behavior.

Added By: Michael Bogaerts at: 12/14/2015 11:43:50 PM    

Dennis,
Is it hidden for a particular reason?

Added By: Dennis (DevExpress Support) at: 12/15/2015 12:29:51 AM    @Michael: Yes.

How to customize ViewNavigator, ViewVisibleInterval and ViewSelector templates

$
0
0

By default the ASPxScheduler control on a page is accompanied with satellite controls, located in the main control's header. They are: ViewNavigator, ViewVisibleInterval and ViewSelector (see the ASPxScheduler visible elements). You can customize their layout and functionality by including custom templates, as illustrated in the following example.

How to customize the Edit Appointment Form in the "Shared Resources" scenario

$
0
0

This example illustrates how the appointment editing form with multiple resources selection can be implemented in a project with ASPxScheduler control bound to SQL Server.

The CarsXtraScheduling.sql file contains the data table script used to create a sample data table at the SQL server.

To switch the scheduler to multi-resource mode, the ResourceSharing property is set to true. A custom appointment editing form is implemented and the appointment field mapping for the ResourceIds property is specified.

Note: starting from the v2009 vol.2 release the standard appointment form contains an ASPxListBox control which provides the required functionality for assigning multiple resources.
For ASPxScheduler releases prior 9.2, the following workaround is used.
A custom appointment editing form contains a data-bound control with multiple selection capability. The control is based on a combination of ASPxCheckBox and ASPxHiddenField controls, enclosed into a Repeater control template.

How to allow appointment modifications depending on custom field values

$
0
0

This example illustrates how to customize the MenuAppointmentCallbackCommand and AppointmentsChangeCommand (see Callback Commands) to prevent appointments with specific custom field values from modification or deletion. Callback commands are intercepted and substituted by their custom equivalents in the ASPxScheduler.BeforeExecuteCallbackCommand Event handler. They determine whether or not a current operation should be denied. If an operation is denied, the base callback command logic is skipped and the ASPxScheduler.CustomJSProperties Event is handled in order to display an error message on the client side (see the client-side EndCallback event handler in the Default.aspx file). This approach might be useful because at present there is no appropriate method to customize the popup menu dynamically (see the Context Menu Items Only for Appointments thread).

See Also:
End-User Restrictions - How to allow appointment creation or deletion only for specific users

How to speed up WinForms apps, running in a Remote Desktop Services environment

$
0
0

To achieve this goal, you can disable visual styles, skins, animations, and set various controls options. Note that here we additionally disable visual effects of two most "expensive" controls: RibbonControl and BarManager, which provide bars, docking functionality, context menus, alert windows and a Ribbon interface for your .NET WinForms applications. The attached example shows how to do this by an example of an XAF Windows Forms application. If you do not use XAF, then you can obtain the necessary code from this example, and put it in the entry point of your application (usually it's the Main method).

IMPORTANT NOTE
1. You can greatly reduce memory consumption if you use the BarManager instead of RibbonControl on your forms. For example, an XAF Windows Forms application with BarManager consumes half as much memory than the same application using the RibbonControl. In XAF you can switch between the standard bars and ribbon menu using the FormStyle property of the Options node in the Model Editor.
2. To avoid painting problems when using the RibbonForm and RibbonControl on Vista or Windows 7 with the Aero theme enabled, don't set the System.Windows.Forms.Application.VisualStyleState property to VisualStyleState.NoneEnabled. Alternatively, you can set the RibbonForm.AllowFormGlass property to false. This is because we use the VisualStyleRenderer to draw text on transparent headers.

See Also:
Add a new static property to the XtraAnimator class which will allow a developer to disable animation in all DevExpress controls
Performance Tuning CPU Use for 16 and 32-bit Windows Applications
Build Your Skills: How to optimize apps to run in Terminal Services
Tuning applications for the Terminal Services
Performance Tuning Guidelines for Windows Server 2008

Question Comments

Added By: Carlitos at: 3/9/2015 10:19:37 PM    

I am trying this code in my windows client but can't get it to work. In the ResolveTemplate method the formTemplate is always null because the IFrameTemplate template is DevExpress.ExpressApp.Win.Templates.Bars.MainFormV2

Added By: Dennis (DevExpress Support) at: 3/10/2015 5:49:28 AM    

@Carlos: Starting with v14.2, new templates for the main and detail forms are used in XAF. So, you should check for the RibbonForm type instead of the XtraFormTemplateBase one from within the ResolveTemplate method when customizing the ribbon template. I have attached the updated code below. We'll consider updating this example accordingly in the future.


[C#]
usingDevExpress.ExpressApp;usingDevExpress.ExpressApp.Templates;usingDevExpress.ExpressApp.Win.Controls;usingDevExpress.LookAndFeel;usingDevExpress.Skins;usingDevExpress.XtraBars;usingDevExpress.XtraBars.Controls;usingDevExpress.XtraBars.Ribbon;namespaceDisableVisualStylesModule.Win{publicclassDisableVisualStylesWindowController:WindowController{publicDisableVisualStylesWindowController(){TargetWindowType=WindowType.Main;}protectedoverridevoidOnActivated(){base.OnActivated();DisableVisualStyles();}protectedoverridevoidOnDeactivated(){base.OnDeactivated();Application.CustomizeTemplate-=Application_CustomizeTemplate;}privatevoidApplication_CustomizeTemplate(objectsender,CustomizeTemplateEventArgse){ResolveTemplate(e.Template);}protectedvirtualvoidDisableVisualStyles(){if(System.Windows.Forms.SystemInformation.TerminalServerSession){Application.CustomizeTemplate+=Application_CustomizeTemplate;InitGlobalOptions();}}protectedvirtualvoidInitGlobalOptions(){Animator.AllowFadeAnimation=false;SkinManager.DisableFormSkins();SkinManager.DisableMdiFormSkins();BarAndDockingController.Default.PropertiesBar.MenuAnimationType=AnimationType.None;BarAndDockingController.Default.PropertiesBar.SubmenuHasShadow=false;BarAndDockingController.Default.PropertiesBar.AllowLinkLighting=false;System.Windows.Forms.Application.VisualStyleState=System.Windows.Forms.VisualStyles.VisualStyleState.NoneEnabled;}privatevoidResolveTemplate(IFrameTemplatetemplate){IBarManagerHolderformTemplate=templateasIBarManagerHolder;if(formTemplateisRibbonForm){InitRibbonOptions(((RibbonBarManager)formTemplate.BarManager).Ribbon);}else{InitBarOptions(formTemplate.BarManager);UserLookAndFeel.Default.SetWindowsXPStyle();}}protectedvirtualvoidInitRibbonOptions(RibbonControlribbon){if(ribbon!=null){ribbon.ItemAnimationLength= 0;ribbon.GroupAnimationLength= 0;ribbon.PageAnimationLength= 0;ribbon.ApplicationButtonAnimationLength= 0;ribbon.GalleryAnimationLength= 0;ribbon.TransparentEditors=false;InitBarOptions(ribbon.Manager);}}protectedvirtualvoidInitBarOptions(BarManagermanager){if(manager!=null){manager.AllowItemAnimatedHighlighting=false;}}}}
Added By: Carlitos at: 3/10/2015 11:22:35 AM    

Thank you Dennis! Works like a charm!!!

Added By: Arjan van Dijk at: 7/14/2015 2:40:57 PM    

You can also consider ngen.exe to speed up

Added By: Paul Berger at: 9/15/2015 10:02:14 PM    

Is there an article like this for VCL?

Added By: Dennis (DevExpress Support) at: 9/16/2015 1:06:48 AM    

@Paul: To process your recent post more efficiently, I created a separate ticket on your behalf: T290221: How to speed up application under Remote Desktop Services (formerly known as Terminal Services) environment. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: manraj patel 2 at: 9/21/2015 5:19:02 AM    

What if I am not using ExpressApp framework in my app?

Added By: Dennis (DevExpress Support) at: 9/21/2015 5:22:03 AM    @manraj: You can just set the RibbonControl, SkinManager, etc. properties manually as shown in the code example above.Added By: Christoph Mark at: 2/6/2018 12:01:12 AM    Using ngen to speed up is really effective!
But you have to take care about your platform:

Ngen can be runned for 32-Bit or for 64-Bit.
32-Bit: C:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe
64-Bit: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe

If your app is running in x64 (or "Any CPU" on 64-Bit-Machine) you need to use ngen-Framework64.

We prefer 32-Bit, because we don't need "benefits" of 64-Bit and 32-Bit runs faster in our environments.

How to set the attitude position of the scale component relative to other gauge elements

$
0
0

In this example we will change the position of the scale in the gauge container. For that purpose the Center property will be used.


How to display detail collections with descendants filtered by an object type

$
0
0

Suppose we have the same classes structure as shown in the How to: Use UpCasting help topic.
Our goal is to provide two details collections into a DetailView that will allow end-users to view objects of the LocalEmployee and ForeignEmployee classes separately in a Department DetailView.
In order to do this, we will declare two calculated details collections in the Department class and also write some code to update these collections when objects are added in or deleted from the main (associated) Employees collections.
By design the Employees collection is intended to list both local and foreign employees and also to allow end-users to perform any operations with them. The LocalEmployees and ForeignEmployees collections are intended to view objects only. So, the corresponding nested ListViews will be readonly.

See Also:
How to: Set Relationships Between Objects
How to: Calculate a Property Value Based on Values from a Detail Collection
How to filter persistent objects against their type
Collection properties and the New/Delete/Link/Unlink Actions

Question Comments

Added By: Willem de Vries at: 9/12/2012 11:36:40 AM    

I'm curious why HintCollection is used despite the documentation stating:
HintCollection - This member supports the .NET Framework infrastructure and cannot be used directly from your code.

Added By: Dennis (DevExpress Support) at: 3/11/2013 2:08:29 AM    

The HintCollection property is used here to specify a data source for an XPCollection.

Added By: Randy Jean at: 12/5/2014 11:07:54 AM    

Is there any way for these descendant collections to not be read-only?  Or, at the very least, when the list view is clicked the detailview is not read-only?  

Also, on the top-level listview (not filtered) can the New button be set to always drop down the list of objects?  Users are complaining that they hit the "button" part of the New and they don't realize there are different objects to choose to add.

Added By: Dennis (DevExpress Support) at: 12/8/2014 4:48:01 AM    >>Is there any way for these descendant collections to not be read-only?  Or, at the very least, when the list view is clicked the detailview is not read-only?  

You can try to remove the following attribute from these auxiliary collections, though I have not tested this particular configuration when creating this example solution:

[ModelDefault("AllowEdit", "False")]

 In general, it is better to use separate Views for editing these collections; e.g., show an editable ListView via a command on the toolbar.



>>Also, on the top-level listview (not filtered) can the New button be set to always drop down the list of objects?
Yes, set the IModelAction.ShowItemsOnClick Property for the New Action via the Model Editor.Added By: Wojciech Gurdek at: 9/8/2017 1:30:17 AM    I try to make editable descendant collections, change attribute [ModelDefault("AllowEdit", "True")]. The new button is visible but records are not stored after add.
When adding records from common listview, the descendant collections not refresh.
How to fix it ?
Added By: Michael (DevExpress Support) at: 9/8/2017 8:18:56 AM    

@Wojciech: We intentionally disabled these operations because the built-in New, Link and Unlink actions are not designed to work with collections that do not participate in relationships.

>>>The new button is visible but records are not stored after add.

In fact, the New action in the LocalEmployees and ForeignEmployees tabs creates objects, but it doesn't link them with the parent. You can create a controller for the nested list view that will subscribe to the NewObjectViewController.ObjectCreated event to initialize the new object, and then to the IObjectSpace.Committed event of the new object's detail view to add it to the collection.

>>>When adding records from common listview, the descendant collections not refresh.

You can subscribe to the XPCollection.CollectionChanged event to update filtered collections as required.

How to prevent removing a master record referenced by other records

$
0
0

This example demonstrates how to implement your classes, to save the referential integrity of your tables when removing master objects being referenced by other objects. This solution is appropriate when you have the Deferred Deletion feature of XPO turned off. Without the code in this example, you will get an SQLException. This solution will allow you to provide your users with more meaningful exceptions, when such a situation takes place.

The Master object in this example has an aggregated One-To-Many relationship to Child objects. If a Master object has some aggregated children, it can be immediately deleted with all associated Child objects. However, if there is a Neighbour object, having a reference (without association) to this Master object, the code will raise an exception, notifying about existing referencing objects.

See Also:
Core - Introduce an automatic check to the deleting algorithm whether an object is referenced by any other object
Deferred deletion and (foreign key) exception handling

OBSOLETE - How to use a security system user as a resource for the scheduler Event object

$
0
0

===================================================
These example implementations are NOT designed for the 'new' security system components (SecuritySystemUser/SecuritySystemRole or PermissionPolicyUser/PermissionPolicyRole) and their scenarios (e.g., middle-tier application server or SecuredObjectSpaceProvider) and thus this code should not be used "as is" with v15.2 or newer.
The Activity (scheduler appointment or event), Employee (scheduler resource or security system user) and Group (security system role) classes' code was once created based on the code of the default Event, Resource and security classes from our DevExpress.Persistent.BaseImpl library. We would like to avoid synchronization and maintenance problems for our users going forward, so it is necessary to update the code of the Activity, Employee  and Group classes based on the ...\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl\ library sources (see the Event.cs, Resource.cs and the PermissionPolicy sub-folder files) according to changes made in the latest XAF versions (15.2+).  The eXpressApp Framework > Task-Based Help > How to: Implement a Custom Security System User Based on an Existing Business Class help topic will be helpful as well.

===================================================


This example demonstrates how to create fully custom classes for use in our Security Module (with the 'old' DevExpress.ExpressApp.Security.SecurityComplex component) and Schedule Module:
    - Activity is an analog of our standard Event class that is used to represent appointments in the Scheduler Control.
    - Employee is an analog of the standard User class, which also supports the IResource interface to use objects of this class as resources in our custom appointment above.
    - Group is an analog of our standard Role class
To enable these two custom security classes in your application set the RoleType and UserType properties for the SecurityComplex component within the Application Designer.

Additionally, the two popular filtering tasks are implemented: filtering appointments by the current logged employee and also filtering resources to show only those owned by the current logged employee.
This functionality is provided by the SchedulerActivityListViewControllerBase class and its descendants as follows:
   a. Administrator account (Sam, to log on, leave the Password field empty) sees all the resources and appointments in the root scheduler view.
   b. Non-Administrator account (John, to log on, leave the Password field empty) sees only his own resources and appointments in the root scheduler view.
   c. Both Administrator and Non-Administrator accounts see their own resources and appointments in the nested scheduler view.
You can use SchedulerActivityListViewControllerBase  and related controllers for study purposes, since they demonstrate the most common filtering scenarios in the scheduler view. If you do not need all this specific functionality, simply remove these controllers and create your own ones (perhaps based on the provided example code) that will do only your specific task. For example, the controllers from this example are not suitable in the nested scheduler view because you miss some part of the default Link/Unlink functionality since the scheduler view is always filtered to show only its own resources and appointments.That may not be desired because you may want to have the capability to link appointments from other resources, but they won't be shown due to the above. Plus, these demo controllers are unnecessary for appointments filtering in the nested scheduler view, because by default, in this view only appointments from the current resources are shown.

Important notes

The IEvent and IResource members are used for appointment and resource mappings and should be declared as public properties. Both XPO and Entity Framework consider public writable properties as persistent (mapped to database columns). If you want to map these properties to columns with different names, use the Persistent or Column attributes in XPO and Entity Framework correspondingly. Alternatively, you can manually calculate property values and decorate interface members with the NonPersistent or NotMapped attributes to specify that these properties are not mapped to columns in the database. If you do not want interface members to be visible in views, use the VisibleInListView, VisibleInDetailView, and VisibleInLookupListView attributes correspondingly.

Question Comments

Added By: Ad de Rijke at: 5/19/2014 4:52:28 AM    

The Web project does not compile: 'The type or namespace name 'WinWebSolutionAspNetApplication' could not be found (are you missing a using directive or an assembly reference?)'

Added By: Dennis (DevExpress Support) at: 5/20/2014 3:31:16 AM    @Ad: For some reason the WebApplication.cs file was emptied. I have attached a working sample for your reference. I will also update this example as well.Added By: Ville Virtanen at: 12/4/2015 11:06:39 PM    

When trying to run it gives an error: Another rule with ID = 'EventIntervalValid' already exists.

When I commented following lines, it worked, but how I disable the BaseImpl rule?

//[NonPersistent]
       //[Browsable(false)]
       //[RuleFromBoolProperty("EventIntervalValid", DefaultContexts.Save, "The start date must be less than the end date", SkipNullOrEmptyValues = false, UsedProperties = "StartOn, EndOn")]
       //public bool IsIntervalValid { get { return StartOn <= EndOn; } }

Added By: Dennis (DevExpress Support) at: 12/7/2015 5:41:37 AM    

@Ville: You can simply rename this rule without commenting it out to avoid this error. Or, you would better not to use the default Event class from the DevExpress.Persistent.BaseImpl library in your project.

Added By: Nate Laff at: 2/17/2016 7:43:43 AM    Can we see an update to this for 15.2? Things are currently pretty broken. In Activity.UpdateEmployees() the XML is coming back much different than it previously did.Added By: Dennis (DevExpress Support) at: 2/17/2016 8:09:23 AM    

@Nate: We will unlikely update this code for v15.2 for the reasons described in point #2 of the important notes to this example. The example's Activity class code is pretty much the same as the code of the Event class (similarly, Employee is an analog of the Event's Resource and security User classes) and we would like to avoid synchronization and maintenance problems for our users going forward.

In the future, I will probably rework this article to be more like a codeless KB article that would focus not on specific implementations, which are different for each concrete business scenario, but rather on the main points of such an integration, which are the same for all cases. I hope this makes sense.

Added By: Paul van Keulen at: 5/25/2016 3:56:20 AM    While compiling this project it gives an error: Error 1 The type or namespace name 'IXpoCloneable' could not be found (are you missing a using directive or an assembly reference?)
Added By: Paul van Keulen at: 5/25/2016 4:01:17 AM    When I remove the IXpoCloneable code I can compile.
After creating an event:

Employee activityUser = Session.GetObjectByKey<Employee>(new Guid(xmlNode.Attributes["Value"].Value));

raises an error.

I'm using 15.2.5. Added By: Dennis (DevExpress Support) at: 5/25/2016 4:14:18 AM    

@Paul: This example code should not be used with v15.2 or later (the version selection is also limited via the example's web page UI). Please refer to point #2 under the Important notes section to learn more on how to proceed with the latest versions. Let us know in case of any further questions on how to apply this guidance.

Added By: Ville Virtanen at: 8/12/2016 2:59:33 PM    Do you plan to update this example to latest version?
Added By: Michael (DevExpress Support) at: 8/15/2016 12:22:42 AM    @Ville: It is unlikely that we will update this example, because the old security system is rarely used nowadays. As mentioned in the description of this ticket, you can find the actual implementation of the Event and Resource classes in the source code shipped with components. As for creating custom security classes, refer to the articles mentioned in the New Security System help topic.Added By: Albert Ortiz Mirabete at: 8/2/2017 5:01:06 AM    Hello,
I use this example to filter resources but the resources are null when executes FilterResources, and never apply the criteria.

[C#]
protectedvirtualvoidFilterResources(XPCollectionresources,CriteriaOperatorcriteria){if(resources!=null&&!ReferenceEquals(criteria,null)){resources.Criteria=criteria;}}

But I have resources and the Scheduler shows all of them when is loaded.
Thanks,
Albert


Added By: Michael (DevExpress Support) at: 8/3/2017 2:24:57 AM    

@Albert: Please refer to the T533005 ticket where a similar issue was discussed. If this doesn't help, submit a new ticket and attach a sample project demonstrating the issue.

Added By: Albert Ortiz Mirabete at: 8/4/2017 7:33:30 AM    Thanks, it works!

How to create an XPClassInfo descendant to dynamically build a persistent class structure

$
0
0

This example is a variation of How to generate persistent classes at runtime based on a dataset with the difference that here we create a custom XPClassInfo class that provides metadata information for a type.
Then, we will use it to bind the GridControl to the XPServerCollectionSource, that is necessary to work in the Server Mode.

Question Comments

Added By: bbirbo at: 4/11/2016 8:21:06 AM    Is there any chance to modify this code so it runs with any sql statement like JOINS etc ?Added By: Andrew L (DevExpress Support) at: 4/12/2016 3:03:33 AM    

Hello,

I've created a separate ticket on your behalf (T366772: It is possible to use the approach described in E1729 so it runs with any sql statement like JOINS). It has been placed in our processing queue and will be answered shortly.

OBSOLETE - How to save an application's settings at runtime and then access them via a common interface from both Windows Forms and ASP.NET platform-dependent modules (Example)

Viewing all 7205 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>