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

How to implement a web handler for the UploadControl

$
0
0

The following example shows how to implement a web handler for the UploadControl.

In this example, the HTTP handler receives files and saves them to a required directory. The file and directory names are passed as a query string parameters.

Question Comments

Added By: Ivan Spasic 1 at: 2/8/2015 3:49:54 PM    

Example doesn't work

Added By: Elliot (DevExpress Support) at: 2/9/2015 1:56:20 AM    

 Would you please make a detailed screencast illustrating the issue (for example, using the Jing Tool) and send it to us? This will make the situation clearer. Thank you for your cooperation in advance.


How to customize a Business Model at runtime (Example).

$
0
0

Sometimes there is a requirement to extend existing business classes from other libraries, add new members, etc.

For instance, you have an assembly where you have declared your persistent classes. Now, you want to use these classes in your XAF application.

Note that to use the types from external assemblies, you should add them to your business model. To do that, you should use the Business Classes section of the Module Designer.


For instance, to force XAF to create navigation items for business classes, usually you can mark them with the DevExpress.Persistent.Base.DefaultClassOptionsAttribute, but what to do if your classes "live" in a separate assembly, which has no references to DevExpress.ExpressApp assemblies.

What to do? In this instance, the XafTypesInfo / XPDictionary customization may be helpful. Currently in XAF using this approach, you can add new attributes to your classes and their members, declare new associations, etc. The only thing, which is not currently supported in XAF, by default, is the capability to declare new classes "on the fly" via customization of the XafTypesInfo / XPDictionary. See a corresponding feature request in this regard:
S19068: Core - Introduce a capability to show a list of calculated (created at runtime) objects with easy

IMPORTANT NOTES

1. By design you cannot dynamically add or remove the OptimisticLocking and DeferredDeletion attributes.
2. Adding custom members for Domain Components (DC) should be done on the XafApplication.SettingUp event as described at DC - Provide support for dynamic members in domain components.



See also:
How to: Access Business Class Metadata

Question Comments

Added By: Denis S at: 11/15/2013 5:58:17 AM    

Update the MyXPOClassLibrary project from Framework 3.0 to 4.0, in order to compile.

How to create a dashboard layout from scratch

$
0
0

The following example demonstrates how to customize a dashboard layout in code.


In this example, the DashboardViewer loads an existing dashboard with the predefined layout form an XML file. The dashboard contains three dashboard items that are placed horizontally side-by-side.

The following steps are performed to create a new layout:

- Three layout items are created to display the existing dashboard items. The weight parameter specifies the layout item size.

- A new layout group is created to display the Grid and Chart dashboard items. The orientation parameter specifies the orientation of layout items within this group.

- A root layout group is created. This group contains the previously created group and the layout item displaying the Range Filter dashboard item.

- The root layout group is assigned to the Dashboard.LayoutRoot property.

See Also:
How to create a new Dashboard, add a Grid dashboard item to it and bind it to data in code

How to customize a layout of the specified group

$
0
0
The following example demonstrates how to change a layout of the specified group in code.

In this example, the ASPxDashboardViewer loads an existing dashboard with the predefined layout from an XML file. The bottom group contains three dashboard items that are placed horizontally side-by-side.

The following steps are performed to customize a group layout:

- Three layout items corresponding to existing dashboard items are obtained using the FindRecursive method. The Weight property specifies the layout item size.
- Child items contained within the bottom group are removed using the RemoveRange method.
- A new layout group is created to display the Combo Box and List Box filter elements. The orientation parameter specifies the orientation of layout items within this group.
- A newly created group and layout item displaying the Chart dashboard item are added to the ChildNodes collection.

How to insert an existing dashboard item to a newly created group

$
0
0
The following example demonstrates how to insert an existing dashboard item in a newly created group using Dashboard API.
In this example, the ASPxDashboardViewer loads an existing dashboard with the predefined layout from an XML file
The following steps are performed to insert the tree view filter element into a newly created group:
- The layout item corresponding to the tree view is obtained using the FindRecursive method.
- The InsertLeft method is used to insert the tree view layout item into the newly created layout group which is used to display a new dashboard item group.
- Finally, the layout item corresponding to the tree view is removed from the layout tree and added to the layout group's ChildNodes collection.

How to manually process search using a custom search panel

$
0
0
This example demonstrates how to create a custom search panel and manually process data obtained from the search request.

GridView - Advanced Master-Detail View

How to implement the master detail GridView with editing capabilities

$
0
0

This example illustrates how to implement the master detail GridView with editing capabilities.
Perform the following steps to define the master-detail layout:
1) Define both master and detail GridView settings within separate PartialView files (see the Using Callbacks);
2) Set the master grid's SettingsDetail.ShowDetailRow property to "True";
3) Define the master grid's DetailRow content via the SetDetailRowTemplateContent method and render the detail grid's PartialView inside.

Note:
Values passed in a detail grid's CallbackRoute must have a unique name and must not replicate any other names on a page: Q577974: GridView - "The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32'" error occurs when canceling editing in the detail GridView


See also:
GridView - Advanced Master-Detail View
A simple example of master-detail grids with editing capabilities

Question Comments

Added By: Wilson Vargas at: 10/20/2012 12:08:04 PM    

This sample not compile!

 settings.DataBinding = (sender, e) => {
            ((MVCxGridView)sender).ForceDataRowType(typeof(DevExpress.Razor.Models.Person));

Added By: WillAutio at: 3/24/2014 1:37:52 PM    

Excellent - just what I needed!

Added By: Paul Astro at: 8/27/2014 12:21:12 PM    

Hello Support,

Is there a ASP.NET version for this exact same example?  Please supply URL link......  thanks.

Added By: Anthony (DevExpress Support) at: 8/27/2014 11:49:39 PM    Hello,

Please refer to the A simple example of master-detail grids with editing capabilities example.

How to move an existing dashboard item to another group

$
0
0
The following example demonstrates how to move an existing dashboard item from the dashboard item group to another group in code.
In this example, the ASPxDashboardViewer loads an existing dashboard with the predefined layout from an XML file
The following steps are performed to move the combo box placed in the bottom group into the top group.
- The required layout items and the dashboard layout group are obtained using the FindRecursive method.
- The MoveAbove method is used to move a combo box layout item above the tree view placed in the top group.
- The Group property specifies a new parent group for the combo box.

How to use NotificationService to show notifications

$
0
0
This example demonstrates how to use NotificationService to show notifications. NotificationService is used in the same manner as other services. When the UseWin8NotificationsIfAvailable option is enabled, it's necessary to use an appropriate ApplicationId. 
This id should be specified in the application shortcut located in the "%APPDATA%\Roaming\Microsoft\Windows\Start Menu\Programs" directory. This is a requirement of the technology. To create a shortcut with the required application id, you can use our DevExpress.Data.ShellHelper class as shown below:
[C#]
DevExpress.Data.ShellHelper.TryCreateShortcut("sample_notification_app","DXSampleNotificationSevice");

Then, assign sample_notification_app to the NotificationService.ApplicationId property:

[XAML]
<dxmvvm:Interaction.Behaviors>     <dxmvvm:NotificationServicex:Name="ServiceWithDefaultNotifications"ApplicationId="sample_notification_app".../></dxmvvm:Interaction.Behaviors>

An advantage of native Windows 8 notifications is that thy can be shown over WinRT applications



How to sort resources

$
0
0

This example shows how you can sort scheduler resources. Actual sorting is performed via the SchedulerStorage.Resources.Items.Sort() method call. Note that custom comparers (see Comparers.cs file) are used to compare resource items by desired criteria (in this example, this is a Resource.Caption Property and a number of appointments, which each resource has). Also, we demonstrated how to prevent sorting (in "ResourceNOfAppointments" sorting mode) for a special "Unassigned" resource. This resource is always displayed first.

The original arrangement order could be easily restored via the SchedulerControl.RefreshData Method. As for the automatic re-sorting when the underlying collection (which is bound to resources) is changed, handle the SchedulerStorageBase.ResourceCollectionLoaded Event. Both approaches are illustrated in this example.

Question Comments

Added By: Gerard D'Rozario at: 2/9/2015 6:34:23 PM    

If the resources that appear can be selected via checkboxes, how do we display the resources in the order they get selected by the end user?  For example there are 3 resources, Room A, Room B, Room C.  At startup none are selected. The user clicks the Room B checkbox and appointments for Room B appear. The user checks the Room A checkbox. Appointments for Room A now appear, but to the LEFT of the Room B appointments. I would like it to appear to the right because that is the order the user selected it. - Thanks.

Added By: George (DevExpress Support) at: 2/10/2015 6:30:38 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T207245: SchedulerControl - How to sort resources in the order they were selected. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to represent a collection property using a checked list box

$
0
0

Scenario:


1. It is required to show a check list. It should be possible to add and remove items for this list dynamically.

2. There are a couple of child records, and it is required to show all available records in a compact manner, and link and unlink them from the master object quickly with check boxes. When an item is checked, this means that this record is associated with the master object.

Steps to implement:


This functionality is implemented via a custom property editor that can be used to edit XPCollection properties. There are two separate editors for WinForms and ASP.NET: WinCheckedListBoxPropertyEditor and WebCheckedListBoxPropertyEditor.

Common implementation details:

1. Create a custom property editor and specify that it should be used for collection properties via the PropertyEditorAttribute.
2. Use a control that can populate the check boxes list based on the passed data source - CheckedListBoxControl in WinForms and ASPxCheckBoxList in ASP.NET.
3. Since an Object Space instance is required to populate the control's data source, implement the IComplexViewItem interface to pass this instance to the property editor.
4. Since control's settings depend on the property value, it is required to configure the control when the value is written to the property editor. An appropriate method is ReadValueCore.
5. Assign the control's DataSource based on the collection's items type, and check the generated list box items that present in the collection displayed via the property editor (it can be accessed via the PropertyValue property).
6. Modify the associated collection when the list box item's checked state is changed. This can be done by handling the CheckedListBoxControl.ItemCheck event in WinForms and ASPxCheckBoxList.SelectedIndexChanged in ASP.NET.
7. Open the Model Editor and assign the created property editor to the PropertyEditorType property of the required view item.

ASP.NET implementation's specifics:

1. Since the ASP.NET property editor (WebCheckedListBoxPropertyEditor) works with the ASPxEditBase descendant (ASPxCheckBoxList), inherit it from the ASPxPropertyEditor class to use the existing code to configure the property editor's settings.
2. ASPxPropertyEditor provides separate methods to create controls - CreateEditModeControlCore to create a control for the Edit mode, and CreateViewModeControlCore for the View mode. Since in both cases it is required to show a check box list, return the ASPxCheckBoxList control in both methods, but disable it in the CreateViewModeControlCore method.

3. Call the ASPxCheckBoxList.DataBind method after assigning the control's data source to generate items.

4. Store object keys instead of entire objects in the editor to avoid issues with transferring data between requests.

5. Override the SetImmediatePostDataScript method to support the ImmediatePostData functionality. It is required to specify what client-side event should be used to raise an XAF callback that passes the new value to the server application. Use the SelectedIndexChanged event.

6. Return False in the overridden IsMemberSetterRequired method to specify that the editor should not be read-only if the bound property is read-only (because collection properties are read-only).

See Also:
S30847
CheckedListBoxControl Class
Implement Custom Property Editors
E1806

Question Comments

Added By: bbirbo at: 2/10/2015 4:44:52 AM    

Does this work with Entity Framework ?

Added By: Anatol (DevExpress Support) at: 2/10/2015 8:55:31 AM    This example is XPO-dependent, since it uses XPCollection as a data source. However, it can be easily converted to EF. To do this, change the way how the dataSource and checkedItems collections are created in the ReadValueCore method. For example, you can use the IObjectSpace.GetObjects method to create a data source for a checked list box control.

How to load Cartesian data to a geographic map

$
0
0
This example demonstrates how to load Cartesian map data to a geographic map.

How to create a custom Theme Selector control

$
0
0

This sample illustrates how to use our theme selector that is used in our demos

How to use the ThemeResource extension to load resources from DevExpress themes dynamically

$
0
0
The ThemeResource extension allows you to load a resource from a currently applied DevExpress theme without specifying the theme name in xaml and reload the resource if a theme is changed. You can reference the resource in xaml as follows:
[XAML]
<BorderBackground="{dxci:ThemeResource {dxt:FloatingContainerThemeKey ResourceKey=FloatingContainerBackground}}"/>

 

See Also:
KA18580 - How to modify DX themes in WPF
K18542 - How to implement the ThemeMananger theme support in custom controls
T128436 - How to use DevExpress themes in a WPF Application


How to use DevExpress themes in a WPF Application

$
0
0

This example demonstrates all common ways of using themes in your application.

DevExpress provides multiple themes that can be applied to all DevExpress WPF controls and some standard controls (GroupBox, ScrollViewer, Scroll, RadioButton, Button, ListBox, Slider, TabControl, Separator, ToggleButton, RepeatButton, Label, ListBoxItem, TabItem, ToolTip, etc.). All built-in themes are described in the following article: DevExpress WPF Themes.

The easiest way to apply a particular theme to the application is to specify the static ThemeManager.ApplicationThemeName property.

To set a theme for a specific element, use the ThemeManager.ThemeName attached property:

 

[XAML]
xmlns:dx=http://schemas.devexpress.com/winfx/2008/xaml/core<TextBoxName="textBox1"dx:ThemeManager.ThemeName="MetropolisLight"Width="120"Height="23"/>

 

In this case, the theme will be applied to the element and all its child elements.

Keep in mind these simple rules when applying DevExpress themes:

1. The ThemeManager.ApplicationThemeName property has lower priority than the ThemeManager.ThemeName property set locally.

2. The ThemeManager.ThemeName property value set for a parent element may be changed for its child if you explicitly specify the ThemeManager.ThemeName property for it.

In some cases, you may need to retrieve a list of all available DevExpress themes. The static Theme.Themes property contains this information.

 
See Also:
KA18580 - How to modify DX themes in WPF
K18542 - How to implement the ThemeMananger theme support in custom controls
T207471 - How to use the ThemeResource extension to load resources from DevExpress themes dynamically

How to: Use TaskbarButtonService

$
0
0
This example demonstrates how to use the TaskbarButtonService.

PropertyGridControl - How to use various editor types based on custom attribute values

$
0
0

In this example, we dynamically generate the PropertyGridControl.PropertyDefinitionsSource and PropertyDefinitionBase.PropertyDefinitionsSource collections based on the underlying data source objects. To generate proper definitions, we implemented a custom PropertyDefinitionTemplateSelector and select one of the following templates based on the underlying property:
1. CollectionDefinitionTemplate. We use it if the underlying property is a collection.
2. CustomDefinitionTemplate. This template is applied only if a specific attribute is set (in this example, we use a custom CustomEditorAttribute).
3. If the underlying object does not meet the previous conditions, we return DefinitionTemplate.

Finally, there is a custom CellTemplateSelector in CustomDefinitionTemplate. In this selector, we check the CustomEditorAttribute attribute value and return one of predefined templates based on it.

How to implement the ThemeMananger theme support in custom controls

ASPxGridView - How to create collapsible columns (client-side approach)

$
0
0

This example demonstrates how to implement collapsible columns. I.e., some columns may be expanded without a round-trip to the server to show additional columns. The main idea is to create two columns: a data column and band column that contain other data columns and change their visibility via CSS when the expand or collapse buttons are clicked. 

See Also:
ASPxGridView - How to create collapsible columns

Viewing all 7205 articles
Browse latest View live


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