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

File Manager - How to generate thumbnails for images on server

$
0
0
File Manager - How to generate thumbnails for images on server

This examples shows how to generate and show thumbnails for image files. The thumbnail generation is implemented in a custom service that returns the thumbnail URLs in ClientFileSystemItem's custom fields. The thumbnails are rendered on the client side in the customizeThumbnail method, similar to the FileManager - Custom Thumbnails demo.

Follow these steps: 1. Add the FileManager to your page and setup it on the client side.
2. Connect the File Manager to your API Controller via the Remote file system provider:
[C#]
@(Html.DevExtreme().FileManager().ID("file-manager").FileSystemProvider(p=>p.Remote().Url(Url.Action("FileSystem","FileManagerApi")))
3. Copy the service implementation from the ThumbnailGeneratorService.cs file. It uses the System.Drawing.Common library that supports .NET Core: System.Drawing.Common - Release Notes.

4. Register the service in Startup.cs:

[C#]
services.AddSingleton<IActionContextAccessor,ActionContextAccessor>().AddSingleton<IThumbnailGeneratorService,ThumbnailGeneratorService>();
5. To use the service, create a method in your API Controller that will handle the File Manager operations and inject the service via Dependency Injection in the following way:
[C#]
publicFileManagerApiController(IWebHostEnvironmentenvironment,IThumbnailGeneratorServicethumbnailGenerator){Environment=environment;ThumbnailGenerator=thumbnailGenerator;}IWebHostEnvironmentEnvironment{get;}IThumbnailGeneratorServiceThumbnailGenerator{get;}publicIActionResultFileSystem(FileSystemCommandcommand,stringarguments){varrootPath=Path.Combine(Environment.WebRootPath,"ContentFolder");varconfig=newFileSystemConfiguration{Request=Request,FileSystemProvider=newPhysicalFileSystemProvider(rootPath,ThumbnailGenerator.AssignThumbnailUrl),...};...}
6. On the client side, use the CustomizeThumbnail method and get the passed thumbnailUrl from fileManagerItem.dataItem:
[C#]
....CustomizeThumbnail("OnCustomizeThumbnail")
[JavaScript]
function OnCustomizeThumbnail(fileManagerItem){ console.log(fileManagerItem);return fileManagerItem.dataItem ? fileManagerItem.dataItem.thumbnailUrl : null;}

NOTE
On Unix-based systems, you may get the "System.TypeInitializationException: The type initializer for 'Gdip' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'libgdiplus': The specified module could not be found" exception. To solve the problem, install gdi+ using the following command:

brew install mono-libgdiplus

How to obtain data on the ResponseCapabilities event

How to obtain a collection of available WMS layers in the RensponseCapabilities event handler

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.

UPDATED:
The Column chooser feature was implemented in v20.1.4 of our Blazor components

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

$
0
0

In v19.2+ XAF Office Module includes the DevExpress WebForms Spreadsheet control. You can use it to display and edit Excel documents (stored in the byte array properties of your business objects). Documentation

How to Localize the Reporting Controls in an Angular JavaScript Application

$
0
0

This example includes the server-side (backend) application that is an ASP.NET MVC application created from the DevExpress Visual Studio template as described in the Report Designer's Server-Side Configuration (ASP.NET MVC) topic.

The client-side (front-end) application is created as described in the Report Designer Integration in Angular document.

To run the example, perform the following steps:

1. Open the CS or VB solution in Visual Studio and rebuild to install the required NuGet packages.
2. Run the Visual Studio project.
3. Open the command prompt, navigate to the JS\angular-report-designer folder and run the commands:
npm install
ng serve
4. Open the URL localhost:4200 in your browser.

See also:

Localization

How to use WorkspaceManager to save layout of multiple controls

$
0
0

WorkspaceManager can be used to save a layout of multiple controls in one container. Only controls that support DXSerializer can be serialized by WorkspaceManager.

To enable WorkspaceManager, set the WorkspaceManager.IsEnabled attached property to true. To save the layout, call the CaptureWorkspace and SaveWorkspace methods.

To correctly save and restore the layout of controls, ensure that all dock items and layout items have the Name properties specified or the BaseLayoutItem.BindableName property bound. If two or more managers are linked, item names must be unique across these managers.

Files to look at:

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

How to localize DevExpress Blazor components

$
0
0

DevExpress components in Blazor applications use the standard localization mechanism from the .NET framework - Satellite Resource Assemblies.
Our components ship with NuGet packages with predefined satellite assemblies for the following languages and cultures:

• German (de)
• Spanish (es)
• Japanese (ja)
• Russian (ru)

To obtain satellite assemblies for DevExpress .NET controls that correspond to other cultures, use the DevExpress Localization Service. This service allows you to modify the existing translations, compile and download the satellite assemblies.

Files to look at:

Blazor Server

Startup.cs
CultureController.cs
Index.razor

Blazor WebAssembly

Program.cs
Index.razor

Blazor DataGrid - How to implement the delete confirmation feature

Drag and drop between detail views when using LINQ to SQL

$
0
0

This example demonstrates how to drag rows between the detail views. When implementing the drag-drop operation on the data source level, it's necessary to made changes in the child view's data source rather than in the GridControl's data source, because LINQ internally caches data, and therefore, the GUI doesn't reflect changes made in another binding context.

Files to look at:

mainForm.cs (VB: mainForm.vb)

How to: Create a Real-Time Chart

$
0
0

The chart processes points that are within its viewport. In this example, points that are beyond the viewport are removed from the data source - starting from the beginning of the collection.

This example shows how to generate a new data point that is added to the chart each time the Timer.Tick event occurs (every 100 milliseconds). The example uses an ObservableCollection as the data source for a series. ObservableCollection notifies the chart about new items, and the chart is rendered again.

Files to look at:

Form1.cs (VB: Form1.vb)

How to: Create a Real-Time Chart and Collect Data in a Separate Thread

$
0
0

The chart processes points that are within its viewport. In this example, points that are beyond the viewport are removed from the data source - starting from the beginning of the collection. The example uses a separate thread to accumulate data points. A new batch of data points is generated every 15 milliseconds. The chart fetches a new portion of points to visualize at a rate of ten times per second.

Files to look at:

Form1.cs (VB: Form1.vb)

WPF Data Grid Getting Started

WPF Blank App with the Northwind Database

$
0
0

This example contains a data access layer generated with Entity Framework Database First. In this example, the blank sample project is connected to the Northwind database.

Database structure:

You can use this example to create DevExpress projects and explore our features.

To connect your project to a database:

1. Add the ADO.NET Entity Data Model to your project:


2. In the Entity Data Model Wizard select EF Designer from database:


3. Click New Connection.

4. Select the Microsoft SQL Server Database File as a data source and specify the path to a database file:


5. Connect to a database:


6. Select tables and views to include them in the model:


7. Set the database's Copy to Output Directory property to Copy if newer:


WPF Blank Dot NET Core App with the Northwind Database

$
0
0

In this example, the blank sample project (.NET Core 3.1) is connected to the Northwind database.

Database structure:

You can use this example to create DevExpress projects and explore our features.


WPF Data Grid Getting Started NET Core

Web Dashboard - How to implement dependent custom properties in a custom item

$
0
0

This example demonstrates how to implement a Custom Item with Custom Properties that depend on each other. We create the following custom properties:

backColorEnabledProperty
backColorProperty
rowBorderVisibleProperty
rowBorderWeightProperty

The UI of backColorProperty is enabled when backColorEnabledProperty is set to true.
The UI of rowBorderWeightProperty is visible when rowBorderVisibleProperty is set to true.

We handle the following ICustomItemMetaData.optionsPanelSections events to implement this behavior:

SectionOptions.onInitialized - for initial configuration,
SectionOptions.onFieldDataChanged - for configuration after changes.

The changeVisibleState and changeDisabledState methods (see CustomItem.js) use the API of the dxForm widget to apply visual state changes. Item content is rendered based on custom property values in the CustomItemViewer.renderContent method.

How to display disabled buttons for particular cells within a ButtonEdit column

$
0
0

This example demonstrates how to display a disabled button for particular cells depending upon some condition. This task can be accomplished by creating a custom button editor. Please refer to the Custom Editors article to learn more about custom editor creation.

The described solution is based on overriding the OnBeginPaint() method of a custom ViewInfo class. This method is called before drawing the editor and applies a desired button state depending upon the condition. Additionally, the RepositoryItemCustomButtonEdit.GetButtonState event is implemented. Subscribing to this event allows a customer to pass any custom condition to the editor. The GetButtonState event handler has the ButtonStateEventArgs parameter, which contains a GridCellInfo class instance as the Tag property. Necessary GridControl data can be obtained from the Tag object.

Files to look at:

CustomButtonEdit.cs (VB: CustomButtonEdit.vb)
Form1.cs (VB: Form1.vb)
Program.cs (VB: Program.vb)

How to create a Candlestick chart

How to load data from a SQL Geometry data source

$
0
0

This example demonstrates how to load data to a vector layer from an SQL Geometry data source.

Description

To load data from the SQL Geometry data source, do the following.

1. Create a SqlGeometryDataAdapter object.
2. Specify its ConnectionString, SqlText and SpatialDataMember properties.
3. Assign this object to the VectorItemsLayer.Data property.

Note that all data table fields loaded from the database will be provided as attributes for each SqlGeometryItem object generated using SqlGeometryDataAdapter.

Files to look at:

Form1.cs (VB: Form1.vb)
Viewing all 7205 articles
Browse latest View live


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