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

How to raise XAF CallBacks from client-side events

$
0
0

In this example, a WindowController implements the IXafCallbackHandler interface, which allows to process CallBacks raised via XafCallbackManager. The example demonstrates how to activate the first navigation item in the selected navigation group when the horizontal navigation is used.


How to Customize Cell Appearance via Templates

$
0
0

This example shows a share of sold units quantity per salesperson. This report contains absolute and percent values, and their graphical representation.

The content of pivot grid cells is replaced via templates, as described below:

1. A class that implements the ITemplate interface is created.
2. An instance of this class is created and assigned to the ASPxPivotGrid.CellTemplate property.

The ASPxPivotGrid passes an PivotGridCellTemplateContainer object to the ITemplate.InstantiateIn method. The PivotGridCellTemplateContainer.Value and Text properties contain the current cell's value and display text, respectively.

When implementing the InstantiateIn method, a web control is created to be rendered instead of the cell's content. This control is added to the PivotGridCellTemplateContainer.Controls collection.

To render a simple text, a LiteralControl is added to the PivotGridCellTemplateContainer.Controls collection.

Example Comments

Added By: Himanshu Sekhar Behera at: 7/17/2013 5:42:19 AM    

This Example giving an error.

How to specify a CSS class for images inserted via the Insert Image dialog

$
0
0

From v2010 vol 2.6 you can specify the CSS class for images inserted via the Insert Image dialog. For this purpose the cssClass field has been added to the GetDialogData_InsertImageForm function within the InsertImageForm.ascx file.
This example demonstrates how to:
- specify a CSS class for the inserted image;
- specify a .css document for an ASPxHtmlEditor;
- customize a default dialog.

Default dialog forms have been copied to the web project for further modification (for details, see Customization of Default Dialog Forms). The ASPxLabel control and ASPxComboBox controls have been added to the ImagePropertiesForm.ascx file markup. The combo box contains tree items specifying names of CSS classes. The GetDialogData_InsertImageForm function has been modified to get the selected CSS class name from the combo box. The image gets CSS class settings from the file, specified via FilePath property (Document.css in our case).

The image below shows the result:

Note

Starting from version 2013.2, image dialogs provide an ability to specify an image CSS class without copying the dialog form to the project. Set the ShowImageStyleSettingsSection property to true to display the image style settings, which include margins, a border and CSS class, in the More options section. You can see this feature in the Custom CSS demo.

How to make PivotGridControl editable when using the Pivot Chart (Analysis) module

$
0
0

Note: PivotGrid controls can be displayed in XAF via two modules - Pivot Chart and Pivot Grid. This example is related to the Pivot Chart module. To learn how to access the PivotGridControl in the Pivot Grid module, refer to the How to access and customize controls used to represent data in list views (PivotGridControl, SchedulerControl, ChartControl, etc.) article.

Scenario:

PivotGridControl displays data in the data area using a certain summary - Sum or Count by default. Thus, when a value of type String or Boolean is displayed, the user does not see real values. This example demonstrates how to show these values and provide the capability to change them. A solution is based on the following XtraPivotGrid example: String editing in the XtraPivotGrid control.

Steps to implement:

1. A ViewController for the Analysis DetailView (PivotGridInplaceEditorsController) is created in the WinForms-specific module.

2. This controller accesses and customizes the Analysis editor (AnalysisEditorWin) in two ways:

2.1. Settings that do not depend on the data source and are not stored in the Analysis object are defined when the View controls are created and when the Analysis object's Data Type is changed. The PivotGridControl is accessed via the AnalysisEditorWin.Control.PivotGrid property.

2.2. Settings related to the PivotGrid fields depend on the data source and are loaded only at certain moments (e.g. when the Bind Analysis Data action is executed). To change them, it is convenient to use a custom field builder, or handle events of the default field builder. The field builder is used by the analysis editor to create PivotGrid fields based on the data source, or restore them based on settings stored in the Analysis object. To access the FieldBuilder, use the AnalysisEditorBase.Control.FieldBuilder property. In this example, a custom FieldBuilder is used to customize field settings.

There are also two other ways to customize the PivotGridControl when its settings are loaded:

1. By handling the AnalysisEditorBase.PivotGridSettingsLoaded event.
2. By handling the AnalysisDataBindController.BindDataAction.Execute event.

These events are appropriate for customizing the existing Analysis reports. However, the PivotGridSettingsLoaded event will not be raised when the Analysis object is just created, and both events are not raised when the DataType of the existing Analysis object is changed.

See Also:
How to make PivotGrid fields invisible when the Analysis view is initialized

Example Comments

Added By: Apostolis Bekiaris (DevExpress) at: 1/16/2013 8:20:39 AM    

See also http://community.devexpress.com/blogs/eaf/archive/2013/01/16/how-to-rule-the-pivot.aspx under the All Pivot cells editable and double paragraph

OBSOLETE: How to filter persistent objects in ListView, according to the users who own them (Complex Security)

$
0
0

==============================
This example is related to the old security system. To learn how to implement this functionality in the new security system, refer to the How to filter records by the current user (the object owner feature) ticket.
==============================


This is the continuation of the E919 example. Here, I've used Many-to-Many relation between users and their resources, and filtered resources by the associated users (owners), if the current user doesn't have the Administrators role.

OBSOLETE - How to customize the XafReport in code and access it before showing the Report Preview

$
0
0

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

This example is now considered obsolete. Please refer to the following help topics to learn how to accomplish the headlined task:
How to: Implement a Custom Report Class
WinReportServiceController.CustomShowPreview Event
================================

This example demonstrates how to create a custom ReportData class to customize XAF Reports. The Header property will be added to the ReportData class, and the corresponding XRLabel control with the Header text will be created in the XafReport. Also, this example demonstrates how to access the XafReport via the ViewController before previewing it. This functionality may be useful, if you cannot access some information from the ReportData class.

See Also:
E908
E2108

OBSOLETE - How to use users as resources for Scheduler

$
0
0

============================
This example will not be maintained any longer, since a similar approach is demonstrated in the How to create fully custom Role, User, Event, Resource classes for use with the Security and Scheduler modules example. Please refer to that example and see how the IResource interface is implemented in its Employee class.
============================


This example demonstrates how to share scheduler events between users when using the Complex Security. For that purpose, the IResource interface will be implemented by the custom user class (User class descendant), and the custom event class will be used.

See Also:
Resources in a Schedule

Example Comments

Added By: Mike Petryk at: 10/29/2012 7:01:11 PM    

Don't make the mistake of decorating the "Id" property with [MemberDesignTimeVisibility(false)] ... None of your users nor will any events that are assigned to your users will appear on the scheduler. I'm not why this is...

OBSOLETE - How to filter persistent objects in ListView, according to the user owning them (Simple Security)

$
0
0

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

This example is related to the old security system. To learn how to implement this functionality in the new security system, refer to theHow to filter records by the current user (the object owner feature) ticket.
=======================================

In ListView, sometimes it's necessary to show only those persistent objects, which were created by a logged-in user. This example demonstrates how you can accomplish this task. The IOwnedObject interface will be added, and the Contact business class will implement it. The FilterByUserController ViewController will release the ListView filtering.


OBSOLETE - XAF.Web: How to set a specific control for the navigation group

$
0
0

This example is obsolete, since this functionality is already available out-of-the-box - see Navigation.

This example demonstrates how to change a control in a specific navigation group. It will show navigation items in the Data navigation group in a tree-like structure.

See Also:
NavBarGroup.ContentTemplate Property
K18005

OBSOLETE: Complex Security Strategy - How to hide roles that do not belong to the current user

$
0
0

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

This example is related to the old security system and is not applicable to the new one.
=======================

In the new Security System it is possible to accomplish this task by creating an Object Permission for the SecuritySystemRole class and specifying the following Criteria in it: "Users[Oid = CurrentUserId()]". Please refer to the New Security System Overview topic for additional information.

Example Comments

Added By: drew.. at: 3/2/2013 8:14:54 PM    

if this is obsolete, should there be a link to the currently accepted practice? thanks..

Added By: Anatol (DevExpress Support) at: 4/2/2013 10:05:41 AM    

I apologize for missing your comment, Drew. I have updated the description of this example.

How to show a complex dialog

$
0
0

Task: We need to ask the user for a number of values by presenting a complex dialog with a number of entry fields nicely arranged.

Solution: An arbitrary dialog can be shown using standard XAF concepts. Any XAF form is a window that shows a certain view. To show a dialog, we create a non-persistent class with properties representing entry fields and show a DetailView of its instance via the PopupWindowShowAction. The class we created is included in the application model and has its default generated detail view, which we can customize to achieve the desired layout. Besides querying simple values, we can add a collection-type property to the dialog class to allow selecting items from the list. This selection can be read in the action's Execute event by accessing ListPropertyEditor representing the nested list view. The popup window displayed via the action contains the usual OK and Cancel action buttons provided by the DialogController. If necessary, you can provide additional action buttons by creating a controller for the dialog class with the Category set to PopupActions.

Note, to show collections in an editable detail view on the Web, use this solution.

How to control the height of grid column headers by setting the number of text lines in the application model

How to serialize parameters of custom types

$
0
0

This example demonstrates the capability to provide XML serialization of custom parameter types.

In particular, it shows how you can save a report, along with its parameters of the System.Enum type, to XML file.

To do this, override the ReportStorageExtension class, and register a custom ReportDesignExtension, which implements the data source serialization functionality.

To serialize custom objects and properties, specify the XtraSerializableProperty attribute with the XtraSerializationVisibility.Reference parameter (this parameter defines whether or not an object should be serialized by a reference).

How to Access the Document Manager

$
0
0

This example demonstrates how to access the Document Manager that the MdiShowViewStrategy uses to show Views. You will see how to locate tab captions to the left and orient them horizontally. For details, refer to the How to: Access the Document Manager topic in XAF documentation.


How to maintain the visibility of components in the End-User Designer


How to implement multi-row editing in the ASP.NET ListView

$
0
0

The ASPxGridView does not natively support multi-row editing. It is recommended to either use the single-row inline editing by setting the AllowEdit property of the ListView model to True in the Model Editor, or edit objects in a DetailView. The multi-row editing functionality is rarely required, but since our customers usually experience difficulties implementing it, I decided to create this example.

There are several examples on how to implement this functionality in the ASPxGridView without XAF. From my point of view, the How to perform ASPxGridView instant updating using different editors in the DataItem template example is the most appropriate for XAF, because:

- this approach can be easily implemented using runtime code

- we already use DataItem templates to show data in grid cells.


All functionality is implemented in a single controller - the MultiRowEditingController. It performs the following operations:

1. Creates an ASPxCallback control and adds it to a page. This control is used to send callbacks from client-side editors used in grid cells.

2. Replaces the default DataItemTemplate with a custom one (EditItemTemplate). The custom template is required to show editors for the user input in grid cells. This template is based on the DataItemTemplate class used in XAF by default. The only difference is that controls from this template are always in the Edit mode.

3. Assigns the client-side script that performs a callback when the value is changed to the editors added to grid cells via the custom DataItemTemplate. This is done in the editor's Init event handler, because at this moment, the NamingContainer that contains the key of the bound object is available.

4. Handles the callback sent from the client side and changes the value of a corresponding object's property.


I recommend that you review the following help topics for additional information:

Access Grid Control Properties
ASPxGridView.Templates Property

See Also:
How to use custom ASPxGridView template in a Web XAF application

Example Comments

Added By: Yuriy Konytskyy at: 6/3/2013 6:44:39 AM    

I doesn't work in v12.2.10

Added By: Anatol (DevExpress Support) at: 7/1/2013 7:19:13 AM    

I have updated the example. Please see implementation details for version 13.1.

Added By: Sandro Welter (Intelligix) at: 7/5/2013 6:02:00 PM    

I'm getting the error below.

The error occurred:
     Type: NullReferenceException
     Message: Object reference not set to an instance of an object.
     Data: 0 entries
     Stack trace:

Added By: Anatol (DevExpress Support) at: 1/10/2014 11:32:12 AM    

The NullReferenceException issue is solved.

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

How to Display Underlying Records

$
0
0

The ASPxPivotGrid includes the drill-down capability, which enables you to retrieve a list of records that were used to calculate a particular summary.

To obtain drill-down data, use the pivot grid's CreateDrillDownDataSource method. Its parameters completely identify a summary cell.

In this example, an end-user can view records from the control's underlying data source, associated with a summary cell, by clicking on it. The obtained data is displayed by the ASPxGridView within a popup window.

How to display a route line with multiple pushpins on a map using a KML file

$
0
0

This example demonstrates how to load a route line with multiple pushpins from a KML file and display these data on a map control.

To do this, create a KMLFileLoader object and assign it to the VectorLayer.ShapeLoader property. Then, specify the path to a KML file using the KmlFileLoader.FileUri property.

Note that if you run this sample as is, you will get a warning message saying that the specified Bing Maps key is invalid. To learn more about Bing Map keys, please refer to the How to: Get a Bing Maps Key tutorial.



How to connect a map control to the Bing Search web service

$
0
0

This example demonstrates how to provide the capability to search for a specific place on a map using the Search panel. The Search panel appears automatically (since the BingSearchDataProvider.ShowSearchPanel property is set to true by default) after you connect to the Bing Search web service.

To find a location on the map, type it on the Search panel.

If the Bing Search service finds alternative places for a request, the "Show others..." option will appear in search results in the Search panel. To go back to the best search result for a place, click "Show best result.."

For example, if you search for "Paris", the "Paris, France" and "Show others..." options will be displayed in the Search panel. Note that the map pushpin shows only the "Paris" location on the map. If you select the "Show others..." option, other search results ("Paris, Lamar Co., TX", etc.) and the "Show best result.." option will be displayed. To see only "Paris, France", click "Show best result.." in the Search panel.

Note that if you run this sample as is, you will get a warning message informing that the specified Bing Maps key is invalid. To learn about how to register a Bing Maps account and create a key for it, refer to the How to: Get a Bing Maps Key tutorial.


Viewing all 7205 articles
Browse latest View live


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