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

Data Source Wizard - How to customize the list of data providers

$
0
0

This example demonstrates how to modify the list of data providers available on the connection parameters configuration page of the Data Source Wizard when customizing the Data Source Wizard by implementing the IWizardCustomizationService interface.

 To obtain the list of available data providers from the internal service container, use the IWizardCustomization.Resolve method. You can delete elements from this list to remove undesired data providers, as well as append new elements to add custom data providers. In this example, all default data providers are removed from the list and a custom provider is added.

 For a custom data provider, specify the connection parameters strategy. The connection parameters strategy is represented by an object implementing the IConnectionParametersStrategy interface and defines which connection settings are required by a data provider, how user input for these settings is handled on the connection parameters configuration page of the Data Source Wizard, as well as how a data source object is created based on these settings.

 For a general code example on how to customize the Data Source Wizard using the IWizardCustomizationService interface, see How to customize the New Report Wizard (introduced in the 2014 vol.1 release) in the End-User Designer.


How to customize connection settings before DashboardViewer connects to a database

$
0
0

This example demonstrates how to customize connection settings before the DashboardViewer connects to a database using the ConfigureDataConnection event.


In this example, the dashboard's XML definition contains a path to the secured Microsoft Access database. To visualize data from this database file, it is necessary to provide connection parameters; in particular, a user name and password for authentication.

The ConfigureDataConnection event is used for this purpose. Its Access97ConnectionParameters.UserName and FileConnectionParametersBase.Password parameters are used to provide the user name and password respectively.

How to import a large data set using XPO efficiently within a transaction

$
0
0
When you are required to import a large data set into a database as XPO persistent objects, the straightforward approach might be inappropriate. Specifically, if you would create objects objects one by one and commit them individually, you cannot roll back changes if one object failed to commit. If you use an XPO transaction or unit of work, changes can be rolled back, but it will require a lot of memory to keep all objects until the final commit.

The solution demonstrated in this example commits objects in small batches by creating a unit of work for each batch and disposing of it after it is committed. To be able to roll back all batches at once, it utilizes the database-level transaction using the XPO data layer's command channel. Although XPO provides a public API for using database transactions (Using Explicit Transactions), it cannot be used in this scenario because explicit transactions belong to sessions, but here we use separate sessions for each batch.

How to control the detail view layout on the web to avoid enormous gaps between the view item caption and the editor

$
0
0
Scenario:

When you have properties in your business class with captions of significantly different lengths, the detail view often looks awkward on the web. This happens because the built-in WebLayoutManager is relatively simple and doesn't support many layout properties that the WinLayoutManager supports (because of the underlying powerful XtraLayout control). Specifically, the item caption length of layout items on the web is calculated as a maximum of all visible items on the detail view. As a result, we have too large a gap between a short caption and the editor when there are long captions.



Solution:

This example demonstrates a possible solution to this common issue by introducing additional properties in the layout group and layout item model nodes.

We create a new model interface that extends the IModelLayoutGroup interface (similar to IModelWinLayoutGroup) with the additional TextAlignMode property. Another model interface extends the IModelLayoutViewItem interface (similar to IModelWinLayoutItem) in the same manner. These properties allow you specify different modes of the caption width calculation for individual items and items in each group separately. Refer to the TextAlignModeGroup and TextAlignModeItem enumerations documentation for options description. These new model interfaces are registered in the web module.

We create a custom layout manager derived from the WebLayoutManager class with the LayoutItem method overridden. In this method, the CaptionWidth is calculated according to new options specified in the item and parent groups it belongs to. The custom layout manager is instantiated in the overridden CreateLayoutManagerCore method of the WebApplication.

Now, the detail view layout can be fine tuned via the Model Editor in the web module in a similar manner as you would in the WinForms application model.


Note how some caption widths are set to local minimums, some set to a a common minimum calculated in the owner or outer group and some widths are calculated globally.

See also:
Extend and Customize the Application Model in Code

 

Question Comments

Added By: Massimo Endrighi 1 at: 1/13/2016 11:31:49 AM    

Could you integrate this functionality in the framework at platform-independent  level ?
The benefits will be:
- the platform independent layout designer will be more WYSIWYG
- there will be no more the need to customize web an windows in the same way.

How to display a check box within column headers

$
0
0

This example demonstrates how to display a check box within column headers. If the check box is checked, the corresponding column is made read-only. Uncheck the check box to allow column values to be edited.

Question Comments

Added By: xiebbs xiebbs at: 9/9/2014 5:34:50 AM    

How to do for Winform ?

Added By: Andrey K (DevExpress Support) at: 9/9/2014 7:05:04 AM    Hi,

I have created a separate ticket on your behalf in order to provide quicker and more efficient responses. We will answer you here: T148932: How to display a check box within column headers

Thanks,
Andrey

OBSOLETE - How to show a specific view for some users

$
0
0

In this example it is demonstrated how to show a custom View against a role of the currently logged user. The custom views were created and customized in the Model Editor for each role separately. For more convenience, the custom views have the name of the role in the Id attribute. For instance: Person_ListView_Administrators, Person_DetailView_Administrators, Person_ListView_Guests, Person_DetailView_Guests, etc. You may consider a specific naming convention, for example, to add a role name to the end of the view name.

There is also a controller that tracks showing views in the application and replaces the default view model with a custom view model found in the application model by the role name.
Alternatively, you can handle XafApplication.UserSettingsLoaded event and patch the ViewID attribute of required navigation items under the NavigationItems node as well as the DefaultListView/DefaultDetailView attributes of the BOModel | Class nodes.

Question Comments

Added By: Serkan Dede 1 at: 1/14/2016 10:27:35 AM    

Hi,

I got error in Application_ViewShowing method on line :
e.View.SetModel(modelView);

Error Message:
Cannot change property 'DefaultSorting' when the XPCollection is not in design or initialization mode.

Any idea to resolve this issue?

How to implement an ability to drag tab headers outside the TabControl to create an external window

$
0
0

In most modern web browsers, it’s possible to drag page headers outside the browser to create a separate external window. This example demonstrates how this functionality can be implemented for the XtraTabControl.

Question Comments

Added By: Zachary Prezioso at: 1/14/2016 11:49:44 AM    

Would it be possible to make it work both ways?
In other words could you drag one window with tabs into the other and add the tabs that way? I'm looking for something that functions similarly to the way Google Chrome handles it.

Thanks,
Zach

Added By: Brendon Muck [DevExpress MVP] at: 1/14/2016 12:31:08 PM    

Zach,

Have you looked at the TabForm class (https://documentation.devexpress.com/#WindowsForms/clsDevExpressXtraBarsTabFormtopic)? I think this might offer you the functionality that you are looking for. If you view the WinForms Browser demo in the Demo Center, I think you'll see that it allows you to drag a tab away to create a new form, and then drag other tabs into that tab to be docked, much like Google Chrome.

Added By: Zachary Prezioso at: 1/14/2016 1:24:48 PM    

Hi Brendon,

Thank you, I did not know about that. I will take a look at it.

How to highlight modified rows


How to export a colored grid when the Data Aware export mode is used

How to export colored GridView

DiagramControl - How to create custom shapes with connection points

$
0
0
The Diagram control supports a special language for defining shapes. The main element that contains shape description is ShapeTemplate. This element describes a shape contour and may contain several segments:
- Start. Specifies the start point
- Line. Defines a line with start and end points
- Arc. Defines an arc with start and end points

To specify connection points, use the ShapeTemplate.ConnectionPoints property.
Shapes may contain parameters. Parameters may be used to dynamically calculate an end point, row height and other properties. To specify parameters, use the ShapeTemplate.Parameters property.
To register custom shapes, use the DiagramToolboxRegistrator.RegisterShapes method.
Question Comments

Added By: Piotr Migdalski 1 at: 1/15/2016 7:12:33 AM    

Hello,

Is possible to use in templates images (from resources)?

How to implement the custom draw functionality for skinned dock panels

$
0
0

This example demonstrates how you can implement the CustomDrawDockPanelCaption event, to manually paint dock panels captions.

Question Comments

Added By: sivasubramanian at: 11/27/2013 10:11:04 PM    

Please attach the Runnable Sample ASAP. Some code snippets are missing in the below Files.

Added By: Jannet (DevExpress Support) at: 11/27/2013 11:30:42 PM    

On reviewing your comment, we have created a separate thread on your bwhalf concenting your inquiry. Please refer to the Q463429 ticket for required details.

How to build non-linear layout via LayoutControl

$
0
0

This example shows how to arrange items within a LayoutControl, forming a non-linear layout. To create a layout, items are combined into groups and the groups are combined into other groups.

Various group visual styles are demonstrated. Group 1 is rendered using the GroupBox visual style (the View property is set to GroupBox), which allows a header to be displayed. There is also a group that represents items as tabs (its View property is set to Tabs). Other groups are painted without a header and borders.

For Group 1, the collapsing feature is enabled via the LayoutGroup.IsCollapsible property, allowing an end-user to collapse the group's contents.

For the tabbed group and the group that displays Item 2 and Item 3, horizontal sizing is enabled via the LayoutControl.AllowHorizontalSizing attached property. Vertical sizing is enabled for Item 4 via the LayoutControl.AllowVerticalSizing attached property.

For items 1, 2, 3, 4 and 6, the VerticalAlignment property is set to Stretch. These items are stretched when the LayoutControl's height is changed. For Item 9 and Item 11, the HorizontalAlignment property is set to Left and Right, respectively. These items have a fixed width and are not stretched when the LayoutControl's width is changed.

How to create a drill-down report in WPF

$
0
0

Starting with version v15.1, the drill-down functionality is available out of the box. Please see the Drill-Down Report module in the Reports for WPF demo application.
See also: How to: Create Drill-Down Reports.

How to use bricks of different types

$
0
0

The following example demonstrates how to use bricks of different types. The code listed in this example creates a report with images (represented by ImageBrick objects) and text (represented by TextBrick objects). Every image displays a picture of a fish, and a text contains species characteristics and its description.

Also, this example demonstrates how to use PageImageBrick and PageInfoBrick objects to show additional information in a page header. For instance, the PageImageBrick displays a DevExpress logo at the top of every page, while two PageInfo bricks display different kinds of information (either the current date and time, or the page number), depending on the PageInfoTextBrick.PageInfo property value.

In addition, this example demonstrates how to add a CheckBoxBrick to a document, and how to use a simple Brick to draw double borders around other bricks.

NOTE
This example demonstrates an outdated approach to creating document sections by setting the BrickGraphics.Modifier property. Refer to T335238: How to: Use Bricks of Different Types to learn how to customize document sections using a printing link's dedicated events.


How to: Use Bricks of Different Types

$
0
0

The following example demonstrates how to use bricks of different types to display different kinds of information in a report.

First, drop a simple button onto a form and handle its Click event. In the event handler, create a new PrintingSystem class instance. Then, create a new Link object and add it to the printing system's Links collection. Subscribe to the link's CreateDetailArea and CreateMarginalHeaderArea events to customize a document's detail and marginal header sections, respectively. Finally, create a document and show it in the print preview by calling the ShowPreview method.

In the CreateDetailArea event handler, use the ImageBrick object to display the picture of a fish and the TextBrick object to show text containing species characteristics and its description. The code also adds a CheckBoxBrick to the document and uses a simple Brick to draw borders around specific bricks.

The CreateMarginalHeaderArea event handler uses the PageImageBrick and PageInfoBrick objects to show additional information in the page header. The PageImageBrick displays the DevExpress logo at the top of every page, while two PageInfo bricks display either the current date and time or the page number, depending on the PageInfo property value.

How to calculate a master property based on values from a details collection

$
0
0

See the How to: Calculate a Property Value Based on Values from a Detail Collection help topic for more information.

See Also:
XPO Best Practices
How to display details collections with descendant classes filtered by object type in a DetailView

Question Comments

Added By: Robert Fuchs at: 1/28/2013 9:01:23 AM    

Not using XAF web, just to let you know that there are warnings in 12.2.5:

Warning     1     Could not resolve this reference. Could not locate the assembly "DevExpress.Web.ASPxEditors.v12.2". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.     WinWebSolution.Web
Warning     2     Could not resolve this reference. Could not locate the assembly "DevExpress.Web.ASPxGridView.v12.2". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.     WinWebSolution.Web
Warning     3     The referenced component 'DevExpress.Web.ASPxEditors.v12.2' could not be found.      WinWebSolution.Web
Warning     4     The referenced component 'DevExpress.Web.ASPxGridView.v12.2' could not be found.      WinWebSolution.Web

Added By: Martin D. at: 6/15/2014 4:22:52 AM    

Hi,

I think this sample needs to be reviewed !
There's a problem with it. If You'd put a breakpoint in Product (line 44 or line 54) - the UpdateTotals.. method - get executed when I click "Reload" in the ListView.

Basically - if I have N+1 records in the ListView, and click refresh, it would go and fetch the details for all child records, and recalculate the "Total" on the master record. Though it should NOT.

That kinda the point of having it persistent right ? So it would get recalculated only when one updates the Details collection !

Added By: Dennis (DevExpress Support) at: 6/16/2014 8:32:42 AM    @Martin: Thanks, I will answer you in E305 sample - is recalculating "header" values on Reload - though it should not  on this.Added By: Arjan van Dijk at: 8/14/2014 2:37:30 PM    

Can you please give me an example using domain components?
Thx

Added By: Dennis (DevExpress Support) at: 8/14/2014 10:53:27 PM    

@Arjan: I am afraid we do not have a ready example for DC. However, to achieve this, use domain logics like AfterChange_PropertyName and others.
Also, a simpler and generic solution will be to use custom calculated fields for this: https://documentation.devexpress.com/#Xaf/CustomDocument3583

Added By: Maen Baghdadi at: 1/19/2016 6:38:08 AM    

Can we extend this example to include the option when delete an Order, the field of the parent Product should be updated accourdingly

How to: Use Services Implementing the IDocumentManagerService Interface

$
0
0
Currently, our MVVM Framework includes a few services implementing the IDocumentManagerService interface:
1. DockingDocumentUIService
2. FrameDocumentUIService
3. TabbedDocumentUIService
4. WindowedDocumentUIService
5. TabbedWindowDocumentUIService
Question Comments

Added By: Ned Stevanovski at: 1/19/2016 6:43:03 AM    

What should I do if I need 5 different WindowedDocumentUIServices ?
(Some windows need to be big, some small, some dialog, some not dialog, some using 1 window template, some using other window template ?

Get values from all cells that are shown at the same level as a clicked cell

$
0
0

You can use the GetCellValue(Object[] columnValues, Object[] rowValues, PivotGridField dataField); method to get a value from a cell by corresponding row and column field values. To iterate through the last level field values use the PivotGridFieldBase.GetVisibleValues method. To get information about higher level values corresponding to a clicked cell use the PivotCellBaseEventArgs.GetColumnFields, PivotCellBaseEventArgs.GetRowFields and PivotCellBaseEventArgs.GetFieldValue methods.


Question Comments

Added By: Leonardo Martínez at: 1/19/2016 1:10:16 PM    

Excelente aporte, mil gracias.

How to validate Captcha and submit model values using $.ajax

$
0
0
This example demonstrates how to implement Model and Captcha validation using $.ajax.The main idea is to use the jQuery serialize function to manually collect values from all inputs inside form. Then pass them to the Controller using $.ajax.
Viewing all 7205 articles
Browse latest View live


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