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

Dashboard Designer in Asynchronous Mode with Object Data Source

$
0
0

This example demonstrates the Dashboard Designer application that loads a dashboard bound to the object data source. The application can switch between synchronous and asynchronous mode.

The following actions are available:

• Click Load Async to switch to the Async mode and load a sample dashboard.
• Click Load Sync to turn off the Async mode and load a sample dashboard.
• Click Reload Data to update the object data source and display the data.

API in this example:

DashboardDesigner.AsyncMode property
DashboardDesigner.AsyncDataLoading event
DashboardDesigner.DataLoading event
DashboardDesigner.ReloadData method
DashboardDesigner.ReloadDataAsync method
DashboardDesigner.DataSourceOptions.ObjectDataSourceLoadingBehavior property

See also:

Asynchronous Mode

Files to look at:

Form1.cs (VB: Form1.vb)

How to show custom popup context menu items only for certain fields

$
0
0

This is an extended version of the How to add a custom popup menu item example. It demonstrates how to hide certain context menu items using the client-side ASPxClientMenuBase.PopUp and ASPxClientMenuBase.CloseUp events. It is possible to use the ASPxPivotGrid.JSProperties dictionary to pass additional information for client side processing.

To get the ID of a target Field Value item use the pivotGrid.fieldMenuFieldID property.
If the Header menu is shown, you can get the ID using the pivotGrid.headerMenuFieldID property.

See also:
How to show a popup context menu's custom items only for certain fields in an MVC solution

Blazor Data Grid - How to edit/delete the selected row by clicking on external buttons

$
0
0

This example illustrates how to start editing/delete the selected row in DxDataGrid programmatically.
Our Data Grid provides the StartRowEdit method, which accepts a data item from the grid's data source.
It's possible to use this method to edit the selected row when some external button is clicked.
Also, this method accepts null as an argument to start a new row editing.

Blazor Date Edit - How to implement the date range selector

$
0
0

This example illustrates how to implement the date range selection scenario. There are two DxDateEdit components, one for the start date and another one for the end date. The Duration variable is used to display the number of days in the selected interval. The MinDuration/MaxDuration variables specify the minimum/maximum number of days in a range.

OBSOLETE - How to use the ASPxSpreadsheet control in an XAF ASP.NET WebForms application

$
0
0

==========================================
This example is obsolete. Refer to the T806194 - ASP.NET WebForms Spreadsheet Editor - Early Access Preview v19.2 help topic instead.
==========================================

Scenario
I want to display my business object that has a byte array property as an Excel document allowing users to modify the content and save it to the database. ASPxSpreadsheet is an appropriate component for this task, but how to implement a Web Property Editor based on it?

Backgrounds
Unlike regular ASP.NET editors and controls, ASPxSpreadsheet is a front-end to a document service similar to Google Docs that will be running on your web site if you add this component to your application. Because of this, a property editor based on the ASPxSpreadsheet component has some specific features.

1. If a user opens a document, the next user who opens the same document will see the actual document content even if the first user did not save it to the database.


2. The Refresh action does not discard changes made in the document. The actual document state is stored in the service, and the content stored in the database is used as backup.

3. The Save action updates the content stored in the database. If the user closed a document without clicking the Save action, changes made to the document will be stored on the service and another user can save them to the database.

The property editor demonstrated in this example works with properties of a specific type - SpreadsheetDocument, and does not write any changes to a property. Instead, it modifies referenced objects directly. The SpreadsheetExample.Module\BusinessObjects\Report.cs (SpreadsheetExample.Module\BusinessObjects\Report.vb) file contains a class that has a property of the SpreadsheetDocument type. Note that this property is considered a part of the persistent object (that is why it has the Aggregated attribute) and automatically initialized with the value within the AfterConstruction method.

The editor implementation is simple. Refer to the SpreadsheetExample\SpreadsheetExample.Module.Web\Editors\SpreadsheetEditor.cs (SpreadsheetExample\SpreadsheetExample.Module.Web\Editors\SpreadsheetEditor.vb) file for details. It uses the ASPxSpreadsheet.Open and ASPxSpreadsheet.SaveCopy methods to synchronize the opened document with the database. Documents are identified by the persistent object's key property. This allows opening a separate document for each record in the database.

ASPxRichEdit - How to insert RTF text to a document

$
0
0

Starting with version 18.1, the ASPxRichEdit control provides the insertRtf command, which allows you to add formatted RTF content at the specified position.
In versions prior to 18.1, ASPxRichEdit doesn't provide a functionality to insert RTF formatted text on the client side so that this format is applied automatically. This example demonstrates a workaround that allows you to insert formatted RTF text to the current document on a button click via an ASPxRichEdit callback.

To implement this scenario, initiate an ASPxRichEdit custom callback via the client-side ASPxClientRichEdit.PerformCallback method and handle the server-side ASPxRichEdit.Callback event. To add the required text in this event handler, you can use the SubDocument.InsertRtfText method.
To insert this text at the current caret position in the middle of a document text, obtain this position on the client side by using the RichEditSelection.intervals array object and pass it to the server as a parameter of the ASPxClientRichEdit.PerformCallback method. Then, access this passed value in the server-side Callback event handler and use it to modify the current document position via the Document.CreatePosition method before inserting RTF text.

See also:
RichEdit - How to insert RTF text to a document

How to Get Dashboard Item Data Asynchronously

$
0
0

This example demonstrates how to get the data displayed in the specified dashboard item asynchronously when the dashboard is loaded.

The labels at the top display the data row count for the specified dashboard item.

screenshot

API in this example:

DashboardViewer.AsyncMode. Switches to the asynchronous mode. The property is set in the InitializeComponent method.
DashboardViewer.GetItemDataAsync method. Gets data displayed within a dashboard item, asynchronously.
• DashboardViewer.Initialized event. Handle this event to perform asynchronous tasks on the first load.

See also:

Asynchronous Mode

Files to look at:

Form1.cs (VB: Form1.vb)

How to Invoke the Data Inspector Asynchronously When the Dashboard is Loaded

$
0
0

This example demonstrates how to call asynchronous methods that retrieves data when the dashboard is loaded.

The Dashboard Viewer loads a dashboard and asynchronously invokes the Data Inspector window.

screenshot

API in this example:

DashboardViewer.AsyncMode. Switches to the asynchronous mode. The property is set in the InitializeComponent method.
DashboardViewer.ShowDataInspectorAsync method. Invokes the Data Inspector window for the specified dashboard item, asynchronously.
• DashboardViewer.Initialized event. Handle this event to perform asynchronous tasks on the first load.

See also:

Asynchronous Mode

Files to look at:

Form1.cs (VB: Form1.vb)

How to Create a Slide Show with Asynchronous Maximize and Restore Methods

$
0
0

This example demonstrates how to call the asynchronous maximize and restore methods to create a slide show with the dashboard items.

screenshot

API in this example:

DashboardViewer.AsyncMode. Switches to the asynchronous mode. The property is set in the InitializeComponent method.
DashboardViewer.MaximizeDashboardItemAsync method. Maximizes the specified dashboard item asynchronously.
• DashboardViewer.RestoreDashboardItemAsync method. Restores the item size if an item is expanded to the entire dashboard size (maximized), asynchronously.

See also:

Asynchronous Mode

Files to look at:

Form1.cs (VB: Form1.vb)

How to Customize the Data Inspector Dialog

$
0
0

This example illustrates how to handle the DataInspectorFormLoad and DataInspectorFormClosing events to get access to the Grid controls in the Data Inspector window and change the grid settings.

API in this example:

DashboardViewer.DataInspectorFormLoad event
DashboardViewer.DataInspectorFormClosing event
DataInspectorFormLoadEventArgs.AggregatedGrid property
DataInspectorFormClosingEventArgs.AggregatedGrid property
DataInspectorFormLoadEventArgs.RawGrid property
DataInspectorFormClosingEventArgs.RawGrid property
GridView.OptionsCustomization property
GridView.OptionsView property
GridView.OptionsBehavior property
GridView.SaveLayoutToStream method
GridView.RestoreLayoutFromStream method

See also:

Data Inspector

Files to look at:

Form1.cs (VB: Form1.vb)

Blazor Data Grid - How to edit a row on a separate page

$
0
0

This example illustates how to create DxDataGrid for Blazor, add a template column with a hyperlink and navigate to a separate page using this hyperlink. The key field value is sent as a parameter.
Then, the necessary record is edited on this separate page and the page is navigated back to the page with DxDataGrid.

Blazor Data Grid - How to bind it to the Web API Service

$
0
0
DxDataGrid for Blazor - How to bind it to the Web API Service

There are two projects:

1. MyTestWebService
2. DataGridWithWebApiService
MyTestWebService

A sample project implementing a web API with ASP.NET Core.

ORM is EntityFrameworkCore.

The data base is "Northwind", and its backup is in this folder.

Restore the backup on your SQL server and change the connection string in this file correspondingly (see the OnConfiguring method).

DataGridWithWebApiService

This project uses the connection to the MyTestWebService web service. Deploy the MyTestWebService project, start it, and specify its address in this file

Blazor Form Layout - How to change DxFormLayout's item and group visibility

$
0
0

This demo illustrates how to implement a form that dynamically displays additional inputs depending on the initial end-user selection. You can specify the visibility of these inputs using the Visible property of the DxFormLayoutGroup and DxFormLayoutItem elements.

Blazor Data Grid - How to show/hide columns based on the value from external UI elements

$
0
0

This example illustrates how to change DxDataGrid's column visibility based on the value of external check boxes.

Bind the Visible property of DataGrid's column and the value of the corresponding check box to the same variable to toggle this column's visibility based on value of this check box.

DevExpress Blazor Components - A way to set predefined settings for the specific component

$
0
0

In the case of a large Web application, you often use controls with the same settings on numerous pages.  It's quite annoying to specify the same settings many times.
In this example we show how to specify some default settings for all DevExpress Blazor components in your application.

Create an inheritor from our Blazor control and override the SetParametersAsync method. In this method, set the necessary default values for the public properties before calling the base method. Since the base method is called after your custom settings, you can initialize properties with custom default values in markup.

In this example, the MyDataGrid component contains the inherited DxDataGrid component whose PageSize, ShowFilterRow, and ShowGroupPanel properties contain new default values. Compare these components with the default DxDataGrid component on the Index page: they have the same settings in markup.

The list of limitations:

• It's not possible to use this approach with the DxChartXXXSeries components and specify the ValueField, ArgumentField, NameField, and PaneField properties.

Note: We don't recommend you override any other members of our components and change values of any protected properties.


How to Bind a Dashboard to the XPO Data Source at Design-Time

XPO - How To Implement Custom Aggregates for Collections of Persistent Objects

$
0
0

In addition to predefined aggregates (Sum, Count, Min, Max, Avg, Single, Exists), XPO users can implement custom aggregate functions. You can use them to query data with XPQuery and data sources that support CriteriaOperator (including server mode collections).

This example illustrates how to use the CountDistinct and STDEVP custom aggregates with XPView and XPQuery (research the Form1 code behind and designer files).

[C#]
// Criteria string for a custom aggregate with a detail collection property or Free Joins."YourCollection.YourCustomAggregate(YourNestedProperty)"// Specific criteria string examples for the Orders collection and the CountDistinct and STDEVP custom aggregates."[Orders][].CountDistinct([ProductName])","[Orders][].STDEVP([Price])"// Criteria string for a custom aggregate with a top-level collection of persistent objects."[].CUSTOM_AGGREGATE('YourCustomAggregate', YourNestedProperty)"// LINQ to XPO usage of custom aggregates (CountDistinct and STDEVP) with a detail collection property.newXPQuery<Customer>(theSession).Select(t=>new{ContactName=t.ContactName,DistinctProducts=(int)CountDistinctCustomAggregate.CountDistinct(t.Orders,o=>o.ProductName),QuantityVariance=(double?)STDEVPCustomAggregate.STDEVP(t.Orders,o=>o.Quantity),PriceVariance=(double?)STDEVPCustomAggregate.STDEVP(t.Orders,o=>o.Price),}).OrderBy(t=>t.ContactName).ToList();

To create a custom aggregate, implement the following interfaces: ICustomAggregate, ICustomAggregateQueryable, ICustomAggregateFormattable.
For more information, research the CountDistinctCustomAggregate and STDEVPCustomAggregate classes in the XpoCustomAggregate/CustomAggregates folder.
To register a custom aggregate, use the CriteriaOperator.RegisterCustomAggregate method (see the Form1 constructor).

See Also
How to: Implement and Use Custom Aggregate Functions

Files to look at:

Form1.cs (VB: Form1.vb)
Form1.Designer.cs (VB: Form1.Designer.vb)
CustomAggregates (VB: CustomAggregates)
DataAccess (VB: DataAccess)

Register Types for Object Data Source Wizard

$
0
0

This example performs the following steps to register object types for the Object Data Source Wizard, which allows users to create an Object Data Source:

• Declares the DataSource and DataSource2 classes that should provide data to reports. The DisplayName attribute is applied to the DataSource class to specify a custom display name for the Report Wizard and Data Source Wizard. The class's name and namespace are used for the DataSource2 class.

• Implements the IObjectDataSourceWizardTypeProvider interface to list data types.

• Implements the IObjectDataSourceConstructorFilterService interface to list only specific data type constructors in the Report Wizard and Data Source Wizard.

• Implements the IObjectDataSourceMemberFilterService interface to list only specific data members in the Report Wizard and Data Source Wizard.

• The RegisterObjectDataSourceWizardTypeProvider<T>(), RegisterObjectDataSourceConstructorFilterService<T>() and RegisterObjectDataSourceMemberFilterService<T>() methods are called at the application's startup to register the interface implementations.

Files to look at

ASP.NET WebForms:

• ObjectDataSource/SampleObjectTypes.cs
• Services/CustomObjectDataSourceWizardTypeProvider.cs
• Global.asax.cs

ASP.NET MVC:

• ObjectDataSource/SampleObjectTypes.cs
• Services/CustomObjectDataSourceWizardTypeProvider.cs
• Global.asax.cs

ASP.NET Core:

• ObjectDataSource/SampleObjectTypes.cs
• Services/CustomObjectDataSourceWizardTypeProvider.cs
• Startup.cs
Documentation • Register Types for Object Data Source Wizard (ASP.NET WebForms)
Register Types for Object Data Source Wizard (ASP.NET MVC)
Register Types for Object Data Source Wizard (ASP.NET Core)

How to retrieve Gantt tasks' predecessor links using the PredecessorLinksSelector

$
0
0

This example demonstrates how to retrieve Gantt tasks' predecessor links using the PredecessorLinksSelector.

In this example, each Gantt task stores links to its predecessors in the GanttTask.Tag property. The property value is a string that contains the predecessors task Id's separated by semicolon (;).
The PredecessorLinksSelector exposes the SelectLinks(object item) method. This method's parameter is a processed Gantt task. The method gets the task's Tag property value, parses it, and returns a collection of the GanttPredecessorLink objects for each task.

Files to look at:

MainWindow.xaml (VB: MainWindow.xaml)
ProjectTaskViewModel.cs (VB: ProjectTaskViewModel.vb)

OBSOLETE - How to override properties of business objects (Example)

Viewing all 7205 articles
Browse latest View live


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