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

How to: Implement Custom Permission, Role and User Objects

$
0
0

This example illustrates how to create custom security objects, such as permissions, roles and users. We will implement a permission that allows administrators to secure the exporting functionality in an XAF application. The complete description is available in the How to: Implement Custom Permission, Role and User Objects topic.

Question Comments

Added By: Leong Vai Long at: 4/30/2014 3:24:41 AM    

Hi DX,
How can I rename these 7 SecuritySystem* tables in database?
How to change their Oid to Int64 instead of GUID? My other BOs are inheriting from XPObject.
Thanks.

Added By: Konstantin B (DevExpress) at: 4/30/2014 4:08:08 AM    Hi Leong,
You can implement security system classes from scratch and use a key propety of a requred type instead of inheriting built-in classes: How to: Implement a Custom Security System User Based on an Existing Business Class

How to calculate PercentVariation and AbsoluteVariation in a custom direction (e.g. from right to left)

$
0
0

This example shows how to use the PivotGridControl.CustomCellDisplayText or PivotGridControl.CustomCellValue event to display a field values as if its PivotGridFieldBase.SummaryDisplayType property is set to PercentVariation, but the values are read in the reverse direction (from right to left).

To accomplish this task, you should create a new PivotGridField, bind it to the DataField, and hide the grand totals for this field via the PivotGridFieldOptions.ShowGrandTotal property. After that, you will need to manually calculate a display text for this field in the PivotGridControl.CustomCellDisplayText event, as shown in the example project.

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.

How to select cells that are placed to the right of the current merged cell in the same row

$
0
0

This example illustrates how to select cells that are placed to the right of the current merged cell in the same row.

How to bind the grid to Columns and Summaries specified in ViewModel

$
0
0

This example shows how to put columns and data summary definition logic in the ViewModel and setup the Grid Control.

Question Comments

Added By: Linzie at: 5/1/2014 9:07:22 AM    

When I tried to run this example, it fails.  Also when I pull up the code in VS2012 (devx controls version 13.2.9) the MainPage.xaml has this part underlined with the following error:
       
           
               
           
       

Part underlined specifically is from FieldName ="{Binding
Error states: The name DependencyObjectExtensions does not exist in the namespace "http://schemas.devexpress.com/winfx/2008/xaml/core".

Any idea what is wrong?

How to inherit grid columns and use them in the XtraGrid

$
0
0

This example demonstrates how to create a GridColumn class descendant and add custom properties to it
For more information, please see the following KB article: How to inherit grid columns and use them in the XtraGrid

Question Comments

Added By: Casey Witt at: 5/1/2014 10:53:55 AM    

In this example, the "Column, Rows, Cells Layout" item in the "Feature Browser" portion of the designer at design time is empty . How to enable this?

How to filter a LookUpEdit in one column based on the value of another column

$
0
0

This example illustrates how to filter LookUpEdit item source values in one column based on the value of another column. This functionality can be implemented only when a filtered LookUpEdit is introduced using a cell template. In this case, every cell has an independent LookUpEdit editor, and we can manipulate its item source. The item source is filtered in the TableView.ShownEditor event handler. This event is raised when a cell gets focus, and its editor becomes active, so it is the best place to filter the item source.

Question Comments

Added By: David Stewart DK at: 1/2/2013 2:11:18 PM    

Notice that in the code below, the Name of the LookUpEdit MUST be "PART_Editor". This particular bit of magic was not clear to me...

/David

Added By: ArunKallingal at: 12/26/2013 5:07:38 AM    

Actually i want this in mvvm concept

Added By: Thomas R Melinsky at: 5/2/2014 4:47:23 AM    

I have compiled this with 12.2.8 and 13.2.7, and it has odd behavior with both.  Sometimes when viewing the cities list, there will only be one item in the list, the chosen city.  Other times when viewing the same city list (or another list item that has the same country selected), it will display all of the city choices.  Is it possible to fix the example as I was planning on using it as a reference?

Added By: Elliot (DevExpress Support) at: 5/2/2014 5:14:23 AM    

As an immediate solution, you can use the approach described in the E2163 code example to avoid this problem. Does it work for you?

How to save and restore a report document from a stream

$
0
0

The following example demonstrates how to save a report document to a stream via the PrintingSystem.SaveDocument method, and then, how to load it via the PrintingSystem.LoadDocument method.

Question Comments

Added By: Thomas R Melinsky at: 7/30/2013 5:09:28 AM    

This example crashes for me with the error X "The specified file cannot be loaded, because it either does not contain valid XML data or exceeds the allowed size." This happens just after hitting the "Load" button, and on the line ps.LoadDocument(stream). I am using 13.1.5.

Added By: jack edwards at: 5/2/2014 12:28:17 PM    

Yep,  same here


How to bind a dashboard to a List object

$
0
0

The following example demonstrates how to bind a dashboard to a List object.


In this example, information about the sold units quantity is provided at runtime. The dashboard data source is created via the Dashboard.AddDataSource method on the first load.

To update the displayed data, the DashboardViewer.ReloadData method is called. This raises the DashboardViewer.DataLoading event and allows supplying the dashboard with updated data.

Question Comments

Added By: GUILHERME ROCHA at: 5/2/2014 2:50:26 PM    

would be possible to load the dashboard of a list of objects in a web project?
In web project there is no "dashboardViewer1.Dashboard = dashboard" property. I tried to replace "ASPxDashboardViewer1.DashboardSource = dashboard" not working. How could I do in this case?

I need use this exemple in web project.. help me!

Unbound Boolean column with the CheckEdit

$
0
0

This example illustrates how to show Boolean values from an external ArrayList via an unbound column, and allow an end-user to edit them.

WinForms SpreadsheetControl API - Part 2

$
0
0

This example is the second part of the SpreadsheetControl API set of examples that demonstrates how to use the SpreadsheetControl API to programmatically manage spreadsheet documents, without the need for Microsoft Excel to be installed.

This sample introduces API properties and methods used to perform the following operations:

- Insert, delete and modify pictures
- Add a hyperlink to a picture
- Add custom functions to the spreadsheet

Starting from v2013 vol.2:

- Create a table
- Apply a custom style to the table



 

Input prompt in a textbox

$
0
0

This sample demonstrates how to utilize client-side API to dynamically display a prompt text
        within a text box depending upon the editor's focused state.

Question Comments

Added By: Jacob Blumberg at: 8/26/2013 2:32:41 PM    

Change the javascript to this to make the prompt text Gray

 function OnTextBoxGotFocus(textBox) {
            if (textBox.GetText() == __initialText) {
                textBox.SetText("");
                textBox.inputElement.style.color = 'black';
            }
        }
        function OnTextBoxLostFocus(textBox) {
            if (textBox.GetText() == "") {
                textBox.SetText(__initialText);
                textBox.inputElement.style.color = 'gray';
            }
            
        }

Added By: Douglas Poston 1 at: 5/5/2014 9:55:21 AM    

What if you have more than one text box on a page or form, how do you pass separate words for each text box to the function? It needs another parameter or something.

Added By: Alessandro (DevExpress Support) at: 5/6/2014 12:10:03 AM    Hi,

I have created a separate ticket on your behalf at:  ASPxTextBox - Extend E4 (Input prompt in a textbox) to display different prompt text in different text boxes. Please refer to this ticket for further correspondence.

How to connect to remote data store and configure WCF end point programmatically

$
0
0

Scenario

In this example, we will create a WCF IDataStore service that will be used by our client (Console Application) as a data layer. Instead of a direct connection to the database, our client will connect to a remote service and configure the WCF end point programmatically. This is usually helpful when: 
- WCF specific customizations are required to provide custom bindings, endpoints, behavior, e.g. for a secured connection;
- Your WCF service is not hosted in IIS and thus no .svc files are used (e.g., when the WCF Class Library project is used).

Steps to implement
1. Create a remote data service and client as described in the How to connect to a remote data service instead of using a direct database connection example.

2. Create an EndPointHelper class which implements the GetDataStore static method as shown in the EndPointHelper.xx file. This method will be used to configure the WCF end point.
The key is in manual creation and custom configuration of the DataStoreClient and CachedDataStoreClient objects (you can see their default configurations by checking the source code of the CreateWCFWebServiceStore and CreateWCFTcpServiceStore methods of the DevExpress.Xpo.XpoDefault class).

3. Use the GetDataStore static method in the Main method as shown in the Program.xx file to configure end point and create a IDataStore.

Important notes
In XAF applications it is necessary to create a class that implements the IXpoDataStoreProvider interface and return the configured IDataStore. For additional information please refer to the How to use a custom ObjectSpaceProvider in XAF example that illustrates implementation of the IXpoDataStoreProvider interface.

 

See also:
Endpoints: Addresses, Bindings, and Contracts
How to connect to a remote data service from a Silverlight application
How to implement a distributed object layer service working via WCF
How to create a data caching service that helps improve performance in distributed applications
How to connect to a remote data service instead of using a direct database connection

 

A simple implementation of FormLayout inside EditFormTemplate

$
0
0

This example demonstrates how to define the FormLayout extension within EditFormTemplate using the SetEditFormTemplateContent method.

How to export report groups to different files

$
0
0

This example illustrates how to group your report and export each group into a separate PDF file.

Question Comments

Added By: Scott Gross at: 5/5/2014 5:48:57 PM    

IS there a way to do this from the Report Server on a schedule?

Added By: Dmitry Tok (DevExpress Support) at: 5/6/2014 5:38:04 AM    

Hi Scott,
The XtraReport is built on the server side in case of using the Report Server. So, I'm afraid that it is impossible to apply the demonstrated approach.
Feel free to contact us in a new support thread or in the existing one if you have any questions.
Thanks


How to connect to a remote data service instead of using a direct database connection

$
0
0

Scenario

In this example, we will create a WCF IDataStore service that will be used by our client (Console Application) as a data layer. Instead of the direct connection to the database, our client will connect to a remote service, which is way more secure and thus important in many enterprise scenarios as database connection settings are not exposed to the client.


Steps to implement

1. Create a new WCF Service Application project and add references to the DevExpress.Data and DevExpress.Xpo assemblies and remove files with auto-generated interfaces for the service.

2. Modify the service class as shown in the Service1 file. This service initializes a connection provider and stores it in the static DataStore property, which is then used by the base DataStoreService class.

3. Change some binding properties as shown in the example's web.config file. At this stage, the service part is ready to work and we need to implement a client to consume data from our data store service (for demonstration purposes, we will create a Console Application).

4. Add the Console Application into the existing solution.

5. Add a new code file for a Customer class using the DevExpress v1X.X ORM Persistent Object item template. See a code of Customer class in the ConsoleApplication\Customer code file.

6. Pass the address of our service into the GetDataLayer method of the XpoDefault class. For this, modify the Main method of the Console Application as shown in the ConsoleApplication\Program code file. Please note that the port number in the connection string may be different. You can check it in the properties of the service project in the Solution Explorer:


As a result, we will see the following output:

Important notes
If you are using an XAF client, then in the simplest case, you can just set the XafApplication.ConnectionString to the address of your data store service (http://localhost:55777/Service1.svc). Refer to the Connect an XAF Application to a Database Provider help article for more details.

See Also:
How to use XPO with a Web Service
Transferring Data via WCF Services
How to connect to a remote data service from a Silverlight application

How to create a data caching service that helps improve performance in distributed applications

How to implement XPO data models connected to different databases within a single application

$
0
0

Scenario

This example demonstrates how to create custom XAF modules with custom business objects and logic that would work with separate databases. These modules do not depend on each other and thus can be reused in other applications as a whole.


Steps to implement

0. Create a new XAF solution using one of predefined project templates;

1. Add two XAF modules into this solution using the DevExpress vXX.X XAF Module project template;

2. Add required persistent classes into these modules as shown in the ClassLibraryN/PersistentClassN.xx files of this example solution;

3. Add service ModuleInfo classes into these modules as shown in the ClassLibraryN/ModuleInfoN.xx files of this example solution;

4. Override the Setup(XafApplication application) methods of your ModuleBase descendants (see the YourModuleName/Module.xx files) as shown in the ClassLibraryX/XafModuleN.xx files of this example solution;

5. Build the solution, invoke the Module Designer for the platform-agnostic module (YourSolutionName.Module/Module.xx), and drag the created custom modules from the Toolbox:

Alternatively, you can add the same modules via the Application Designer invoked for the executable projects (as demonstrated in this example).

6. Declare connection strings in the configuration files of your application as shown in the TwoXpoModelsForDifferentDatabases.Web\Web.config and TwoXpoModelsForDifferentDatabases.Win\App.config files (see ConnectionStringDatabaseX under the <connectionStrings/> element). These connection strings are used in the modules via the ConfigurationManager.ConnectionStrings API, but you can always modify the way your modules obtains this data.

Important notes

1. Each module has a single static XPObjectSpaceProvider instance, which is initialized only once during the application life cycle.

2. Each ModuleUpdater class checks the ObjectSpace property to determine whether it is valid to create initial data of a certain type from this module.

See also:
How to prevent altering the legacy database schema when creating an XAF application

How to Conditionally Apply Styles (CellStyle)

$
0
0

This example demonstrates how to apply a custom style to cells displayed within the 'Product Name' column based on a custom condition. A product's name is highlighted if the number of units is less than 20.

Question Comments

Added By: Bharadwaz Avvari at: 5/7/2014 2:38:37 AM    

there is No color change in the this example. I think something is missing please check it once again. and Re post it

Added By: Elliot (DevExpress Support) at: 5/7/2014 3:26:29 AM    This issue will  be processed in the How to Conditionally Apply Styles (CellStyle) ticket.

GridView - How to calculate a summary value for selected rows only

How to use DevExpress extensions inside custom helpers

Viewing all 7205 articles
Browse latest View live