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

How to implement the Rest service based on an ASP.NET WebAPI application

$
0
0

This example demonstrates how to implement the Rest service based on an ASP.NET WebAPI application.

See also:
How to configure ODataService for a DevExtreme HTML5/JS application
Creating a REST service using ASP.NET Web API
An Introduction To RESTful Services With WCF
How to implement CRUD operations with a DataSource

Question Comments

Added By: Nikolai (DevExpress Support) at: 10/6/2015 12:35:29 AM    Hi Matthias,

Please post your comments regarding this issue in the Accessing data source in dxDataGrid for updating Id from ControllerAction ticket.Added By: Milind Wadge 1 at: 11/22/2017 6:32:42 AM    In this example, you have created queryhelper class which is specific to category object.
Can we generate a single generic queryhelper class which can be used in any object controller?

How to: show stacked bars' total labels at runtime

$
0
0
This example demonstrates how to show stacked bars' total labels.

How to custom draw in PDF Viewer

$
0
0
The PDF Viewer can draw graphics in the PDF document in the Control.Paint event handler.

In this example, the filled rectangle is drawn at any document space when you hold down the left mouse button and move it. 
Question Comments

Added By: Milind Wadge 1 at: 1/4/2017 11:34:31 PM    

After draw of rectangle, How can I save PDF document with drawn rectangle?.

Added By: Mariya (DevExpress Support) at: 1/5/2017 3:09:36 AM    

Hello Milind,

I've created a separate ticket on your behalf (T468966: How can I save a PDF document with the drawn rectangle). It has been placed in our processing queue and will be answered shortly.

Added By: James Cahill 1 at: 11/22/2017 10:35:11 AM    Is it possible to achieve this functionality of drawing on the PDF Viewer in WPF? v17.1.6

(Obsolete) dxTreeList - How to implement recursive selection

How to show a dashboard item's client and underlying data for a clicked visual element

$
0
0

This example demonstrates how to obtain client and underlying data corresponding to a particular visual element and display this data in a popup. You can click individual cards within the Card dashboard item to see detailed information.

How to display the Stacked Bar total value labels

How to toggle a row's visibility

$
0
0

This example demonstrates how to implement a helper class which implements the ShowRow() and HideRow() methods to manage rows' visibility with ease.

Question Comments

Added By: Joe How Hu¡ at: 11/24/2017 1:40:51 AM    Dear support, could you please upload VB.NET version of code in this example?

How to create a custom save button in ASPxRichEdit with automatic enabling/disabling

$
0
0

This example illustrates how to create a custom save button with automatic enabling/disabling. This means that if a document was not changed, the save button is disabled. As soon as the document is changed, the save button is enabled. 


Web Dashboard - How to show a dashboard item's client and underlying data for a clicked visual element

$
0
0

This example demonstrates how to obtain client and underlying data corresponding to a particular visual element and display this data in a popup. You can click individual cards within the Card dashboard item to see detailed information.

How to customize the appointment flyout

How to toggle a row's visibility

$
0
0

This example demonstrates how to implement a helper class which implements the ShowRow() and HideRow() methods to manage rows' visibility with ease.

Question Comments

Added By: Joe How Hu¡ at: 11/24/2017 1:40:51 AM    Dear support, could you please upload VB.NET version of code in this example?

DataGrid - How to use DropDownBox as a column editor in edit mode

How to import data from a DataTable instance into a SpreadsheetControl

$
0
0

This example illustrates how to import data from the DataTable Class instance into a SpreadsheetControl. We use the Worksheet.Import() overloaded method from the DevExpress.Spreadsheet.WorksheetExtensions class located in the DevExpress.Docs.vXY.Z.dll assembly. In addition, use the WorksheetCollection.ActiveWorksheet and Worksheet.SelectedCell properties to place the data relative to the selection in the SpreadsheetControl.

See Also:

How to import data to worksheet cells from different data sources and use tables

Question Comments

Added By: Sammy Hale at: 11/24/2017 1:20:04 PM    This doesn't work anymore!!!!

How to enable the circular scrolling functionality for tiles and vector items

How to make a Lookup editor function as a regular ComboBox

$
0
0

A Lookup editor is a kind of editors that can only display those values that are present in its dropdown list. Such editor can't display any value in its edit box. When a user types a value in the Lookup editor edit box, the ProcessNewValue fires. This event allows you to handle this situation and add the typed value to the editor's datasource. In this case, this value won't dissappear when the editor is validated.

However, if you need to have a fixed dropdown list and don't want to change the editor's datasource, this solution is not suitable for you. To overcome this problem, it's necessary to create a custom datasource wrapper. This wrapper will store the last typed value, and that's why the Lookup editor will show this value without any problem. However, this change won't affect a wrapped datasource.

This example is based on the How to create a data source wrapper that adds an empty item to the lookup list example. The only requirement is that your datasource should implement the ITypedList interface. You see that you can modify your original datasource values, and these changes will be automatically displayed in the GridLookUpEdit's datasource. However, changes made within the ProcessNewEvent event handler won't affect your original datasource.

Question Comments

Added By: Curtis Francis at: 9/20/2012 8:27:10 AM    

I successfully implemented this in my own project, with one small caveat that I've noticed so far. Let's say I have a data source with the values One, Two, and Three in it. My user types Four and saves the form.

Then, the user opens the form again. My code says "GridLookUpEdit1.EditValue = "Four". But "Four" is not displayed in the GridLookUpEdit and the ProcessNewValue event doesn't fire. I realize I can manually look for "Four" in the datasource and if it's not there, I can set it before setting EditValue. However, I'm wondering if there's a way I can simply set the value in the GridLookUpEdit control and have the ProcessNewValue triggered, which I believe would take care of all this automatically for me.

Added By: Bernhard Geist at: 11/26/2017 11:51:04 PM    Example throws Exceptions System.IndexOutOfRangeException in System.dll

How to show multiple group summary values in the same group footer cell

How to copy a page from one document to another one

$
0
0
This example shows how to extract a page from one PDF document and insert it to another PDF. 

How to print the scheduler using Scheduler Reporting

$
0
0
This example demonstrates how to print the Scheduler control using the Scheduler Reporting technique. The Scheduler control is bound to MS SQL database created on demand using the Entity Framework CodeFirst approach. The Print Scheduler command in the Ribbon loads the Scheduler Report template and invokes the Document Preview window. The Preview window enables the end-user to print the report or save it to PDF.

How to customize the underlying database provider options and data access behavior in XAF

$
0
0

IMPORTANT NOTE

This article describes some advanced customization techniques and low-level entities of the framework with regard to data access, which may be required in complex scenarios only.
So, if you just want to change the connection string, e.g. to use the Oracle instead of the Microsoft SQL Server database, then you would better refer to the Connect an XAF Application to a Database Provider article and documentation on your database provider instead. The XAF integration of supported ORM libraries is also described in the Business Model Design section of the framework's documentation.


Introducing IObjectSpaceProvider and IObjectSpace
XAF accesses data from a data store through special abstractions called - IObjectSpaceProvider and IObjectSpace.
The IObjectSpace is an abstraction above the ORM-specific database context (e.g., the DBContext used in Entity Framework or the Session in XPO) allowing you to query or modify data.
The IObjectSpaceProvider is a provider/creator of IObjectSpace entities, which also manages which business types these IObjectSpace are supposed to work with, how to set up the underlying connection to the database, create and update it and other low level data access options.



An XafApplication can use one or several IObjectSpaceProvider objects at the same time, and you can access this information through the XafApplication.ObjectSpaceProvder or XafApplication.ObjectSpaceProviders properties. Check out these help links to learn more on how to plug in custom IObjectSpaceProvider objects a well.

There are several built-in implementations of the IObjectSpaceProvider and IObjectSpace interfaces in our framework, which are usually specific to a target ORM (Entity Framework or XPO). I suggest you check out the source code of the default framework classes to better understand the role of the IObjectSpaceProvider:

...\DevExpress.ExpressApp.Xpo\XPObjectSpaceProvider.cs
...\DevExpress.ExpressApp.EF\EFObjectSpaceProvider.cs 

Typical customization considerations
You may want to provide a fully custom IObjectSpaceProvider implementation or inherit from the built-in implementors when you want to customize how data access is performed for a chosen ORM.
Below is a list of typical scenarios where a custom IObjectSpaceProvider may be required:

1. How to use XPO caching in XAF 
2. How to prevent altering the legacy database schema when creating an XAF application 
3. How to connect to remote data store and configure WCF end point programmatically 
4. How do I map persistent classes to another schema, e.g. other than the default "dbo" in MS SQL Server?
5. How to use a custom ObjectSpace throughout the application by handling the CreateCustomObjectSpaceProvider event? 
6. How to connect different ORM data models to several databases within a single application

In most cases, it is not required to implement the IObjectSpaceProvider interface from scratch since you can inherit from existing implementors or customize/just their parts.


XPO-specific customizations

1. Implementing IXpoDataStoreProvider

For instance, in XPO one of such replaceable parts is the IXpoDataStoreProvider interface, which enables you to provide a custom or configured IDataStore object, which is used for underlying data access with this ORM:

[C#]
publicinterfaceIXpoDataStoreProvider{IDataStoreCreateWorkingStore(outIDisposable[]disposableObjects);IDataStoreCreateUpdatingStore(outIDisposable[]disposableObjects);stringConnectionString{get;}}

 

In its turn, XAF provides several ready to use implementations of this interface for most popular scenarios: 

1. ConnectionDataStoreProvider - can provide IDataStore by the IDbConnection object;

2. ConnectionStringDataStoreProvider - can provide IDataStore by just connecting string information;

3. MemoryDataStoreProvider - DataSet based in-memory IDataStore providers.


Technically, such an IXpoDataStoreProvider part is passed into the XPObjectSpaceProvider constructor as a parameter, which means that you can just customize it instead of re-implementing the whole XPObjectSpaceProvider logic:

Consider the following example that shows how to access the underlying XPO connection provider for modifying its default command timeout:

[C#]
//In your XafApplication descendant class (e.g., in the YourSolutionName.Win/WinApplication.cs file).usingDevExpress.ExpressApp.Xpo;usingDevExpress.Xpo.DB;usingSystem.Data;...protectedoverridevoidCreateDefaultObjectSpaceProvider(CreateCustomObjectSpaceProviderEventArgsargs){args.ObjectSpaceProvider=newXPObjectSpaceProvider(newMyIXpoDataStoreProvider(args.ConnectionString,args.Connection,false),true);args.ObjectSpaceProviders.Add(newNonPersistentObjectSpaceProvider(TypesInfo,null));}publicclassMyIXpoDataStoreProvider:IXpoDataStoreProvider{privateIXpoDataStoreProviderinnerDataStoreProvider=null;publicMyIXpoDataStoreProvider(stringconnectionString,IDbConnectionconnection,boolenablePoolingInConnectionString){innerDataStoreProvider=XPObjectSpaceProvider.GetDataStoreProvider(connectionString,connection,enablePoolingInConnectionString);}publicstringConnectionString{get{returnthis.innerDataStoreProvider.ConnectionString;}}publicIDataStoreCreateSchemaCheckingStore(outIDisposable[]disposableObjects){returninnerDataStoreProvider.CreateSchemaCheckingStore(outdisposableObjects);}publicIDataStoreCreateUpdatingStore(boolallowUpdateSchema,outIDisposable[]disposableObjects){returninnerDataStoreProvider.CreateUpdatingStore(allowUpdateSchema,outdisposableObjects);}publicIDataStoreCreateWorkingStore(outIDisposable[]disposableObjects){IDataStoreds=innerDataStoreProvider.CreateWorkingStore(outdisposableObjects);ConnectionProviderSqlconnectionProvider=dsasConnectionProviderSql;if(connectionProvider!=null){// Can be null if connection pooling (DataStorePool) is used.connectionProvider.DefaultCommandTimeout= 100;}returnds;}}...

Refer to the ...\DevExpress.ExpressApp.Xpo\XPObjectSpaceProvider.cs file within the XAF source code to better understand the role of this part.

2. Handling the DataStoreCreated event of ConnectionDataStoreProvider and ConnectionStringDataStoreProvider 
Instead of creating your own IXpoDataStoreProvider  from scratch, it is often simpler to explicitly create a ConnectionDataStoreProvider or ConnectionStringDataStoreProvider instance (an IXpoDataStoreProvider implementer) and subscribe to its DataStoreCreated event (available starting with version 17.2).  The event arguments (DataStoreCreatedEventArgs) expose the DataStore and Destination parameters that provide access to the current data store and its type (SchemaChecking,  Updating or Working). Refer to the How do I map persistent classes to another schema, e.g. other than the default "dbo" in MS SQL Server?  example for more details.

 

3. Overriding XPO connection or database providers

To learn more on this approach, check out the Database Systems Supported by XPO help topic and How to create a custom XPO connection provider and then use it in an XAF application article in particular.  To learn more on customizing data access settings for XPO, please refer to the corresponding product documentation: Data Access Layer.



See Also:
Can I connect an XAF application to a custom data source (Web service, OData service, NoSQL database, etc.)?

Question Comments

Added By: Rejoice Supsup at: 9/16/2015 11:33:05 AM    

Is this intended to contain an empty example resource?

Added By: Dennis (DevExpress Support) at: 9/16/2015 11:46:15 AM    

Yes. This article originally contained an example, but it is now more like a KB article.

Added By: Rejoice Supsup at: 9/16/2015 12:00:10 PM    

Thank you for the quick reply. But I thought this might be misleading since it's categorized as an example. Should I expect that you're be providing an example in the future? If I may suggest, what about 2 databases:

#1 - Departments and Employees
#2 - Customers and Orders

Where #1 is integrated with the Security Module and #2 (used by XAF Win Forms) to manage CRM data but will be authenticated via DB #1.

Added By: Dennis (DevExpress Support) at: 9/16/2015 12:16:34 PM    

The category is to be changed in the future as the main purpose of this article is to describe the main concepts.
There are already multiple examples mentioned in this article - see under the "Typical customization considerations" section (no plans for new examples so far). I hope you find them helpful to implement your particular scenario. Should you have any further difficulties with your own implementation, please submit a separate ticket and attach your sample showing what you tried to do and what did not work as expected. Thanks.

XtraGrid - How to draw a GridControl background image

$
0
0

This example demonstrates how to draw an image behind the GridControl rows

Question Comments

Added By: Dennis Gascoigne at: 11/27/2017 9:16:47 PM    Does not work in 17.2.3
Viewing all 7205 articles
Browse latest View live


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