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

Unit Conversion Library code samples

$
0
0

This example illustrates how to use the Unit Conversion Library to create a QuantityValue object that represents a pressure value, assign a value measured in millimeters of mercury and gets the same value measured in hectopascals.

The Universal Subscription or an additional Document Server Subscription is required to use this example in production code. Please refer to the DevExpress Subscription page for pricing information.


Spreadsheet Document Server API - Part 2

$
0
0
This example demonstrates how to use the Spreadsheet Document Server API to programmatically manage spreadsheet documents, without the need for Microsoft Excel to be installed.
The application includes the RichEditControl  used to display and edit the code. The code modifies the spreadsheet document loaded in the Workbook instance. To see the results, open the document in Microsoft Excel by clicking the button.
You can modify the code and watch the result. If an error occurs during compilation or execution, the backcolor of the code window changes.

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

- Insert, delete and modify pictures
- Add a hyperlink to a picture
- Create a table
- Apply a custom style to the table
- Protect a workbook
- Protect a worksheet
- Apply user-specific permissions to a range in a protected worksheet
- Sort a range in descending and ascending orders
- Sort by multiple columns
- Simple search
- Search with options
- Export to HTML
- Group and outline data
- Insert subtotals
- Filter data by a list of values
- Apply a number filter
- Apply a text filter
- Apply a dynamic filter
- Sort the filtered data

For more information, review the Examples section in the documentation.

The Universal Subscription or an additional Document Server Subscription is required to use this example in production code. Please refer to the DevExpress Subscription page for pricing information.

How to reference an external workbook

$
0
0
This example demonstrates how to insert an external reference link from a workbook to another workbook.
An external workbook is created and populated with random data by importing a data table at runtime.
Subsequently the workbook is added to the ExternalWorkbookCollection.
A cell formula with a reference to an external workbook is inserted in the current worksheet. The worksheet is saved to .XLSX file and opened with an application registered for that file format.

See also the Cell Referencing documentation topic available online.

The Universal Subscription or an additional Document Server Subscription is required to use this example in production code. Please refer to the DevExpress Subscription page for pricing information.

How to create and display a BarCode in a web application

$
0
0

This example illustrates how you can use our new Bar Code Library in ASP.NET to generate and display a barcode image on the webpage. The best approach implies creating a custom HTTP Handler that will generate and output an image. Here is a code of this handler:

 

[C#]
publicclassBarCodeHandler:IHttpHandler{publicvoidProcessRequest(HttpContextcontext){BarCodebarCode=newBarCode();barCode.Symbology=Symbology.QRCode;barCode.CodeText="123";context.Response.ContentType="image/png";barCode.Save(context.Response.OutputStream,ImageFormat.Png);context.Response.End();}publicboolIsReusable{get{returnfalse;}}}

 

The img tag in the main aspx page is defined as follows:

 

[ASPx]
<imgsrc="BarCodeHandler.ashx"alt="QRCode"width="200px"height="200px"/>

 

See Also:

HTTP-handler for image

The Universal Subscription or an additional Document Server Subscription is required to use this example in production code. Please refer to the DevExpress Subscription page for pricing information.

Question Comments

Added By: ABRAMO ABRAMO at: 6/14/2013 2:12:48 AM    

I get Server Error in '/E4716' Application when I click "Run Online"

Spreadsheet Document Server Chart API

$
0
0
This example demonstrates how to use the Spreadsheet Document Server Chart API to programmatically manage charts in worksheets.
The application includes the RichEditControl  used to display and edit the code. The code modifies the spreadsheet document loaded in the Workbook instance. To see the results, open the document in Microsoft Excel by clicking the button.
You can modify the code and watch the result. If an error occurs during compilation or execution, the backcolor of the code window changes.

Starting from v2015 vol.1:
- Insert and modify sparklines

The Universal Subscription or an additional Document Server Subscription is required to use this example in production code. Please refer to the DevExpress Subscription page for pricing information.

How to automatically create mail-merge documents using the Snap Document Server

$
0
0

This example demonstrates how to use the Snap API to automatically generate master-detail mail merge documents by the DevExpress Snap Document Server.

After running this example, a console application creates a document that is exported to an RTF file and opened by default program.

See also: How to provide custom separators for records of a mail-merge document.

The Universal Subscription or an additional Document Server Subscription is required to use this example in production code. Please refer to the DevExpress Subscription page for pricing information.

Question Comments

Added By: Alexandros Pappas 1 at: 7/21/2015 12:05:58 AM    

Can you please explain how you create the template.snx file?

Added By: George (DevExpress Support) at: 7/21/2015 4:17:38 AM    

Hi,

To process your recent post more efficiently, I created a separate ticket on your behalf: T269397: How to create a template.snx file. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to export a worksheet with embedded charts to PDF

$
0
0

To export a worksheet to PDF, use the Workbook.ExportToPdf method.

However, to export embedded charts, it is necessary to register the following services:

DevExpress.XtraSpreadsheet.Services.Implementation.ChartControllerFactoryService
DevExpress.XtraSpreadsheet.Services.Implementation.ChartImageService


The Universal Subscription or an additional Document Server Subscription is required to use this example in production code. Please refer to the DevExpress Subscription page for pricing information.

How to implement browser-style tab behavior in DXTabControl using StretchView

$
0
0

One of DXTabControl's supported views is TabControlStretchView. This view automatically stretches tab headers to all available space in the Tab Header Panel and allows dragging tabs in the browser-style manner. To control the dragging behavior, use the DragDropMode property. In addition to this functionality, TabControlStretchView allows pinning tabs to the right or left side of the Tab Header Panel. To pin a tab, use the TabControlStretchView.PinMode attached property.


GridView - How to implement a custom HeaderFilter with a calendar for a date column

$
0
0

v15.2
This example is now obsolete. Starting with v15.2, we implemented a new GridViewDataColumnHeaderFilterSettings.Mode property.  Please refer to the Date Range Header Filter demo.


For older versions:
 

This example illustrates how to create a custom HeaderFilter for a date column. The main steps are: 
1) create a custom HeaderTemplate using the  SetHeaderTemplateContent method to prevent default header filter button logic and implement a custom one;
2) use the PopupControl to display a Calendar and several additional filters. FormLayout is used to build  a layout;
3) use the client AutoFilterByColumn method to perform filtering from the client side and the MVCxClientGridView.PerformCallback  method to pass a complex filter expression to the server to implement custom filtering;;
4) process a custom callback in the action method defined using the CustomActionRouteValues property and pass information about the current filter command to a partial view;
5) assign a delegate method to the BeforeGetCallbackResult property and implement the approach described in the ASPxGridView - How to programmatically change the column's filter in the FilterExpression  help article  to apply a new filter.

Click on the "Model Date" column to check how this works.

Web Forms:
ASPxGridView - How to implement a custom HeaderFilter with a calendar for a date column

ASPxGridView - How to implement a custom HeaderFilter with a calendar for a date column

$
0
0

v15.2
This example is now obsolete. Starting with v15.2, we implemented a new GridViewDataColumnHeaderFilterSettings.Mode property.  Please refer to the Date Range Header Filter demo.


For older versions:


This example illustrates how to create a custom HeaderFilter for a date column. The main steps are: 
1) create a custom HeaderTemplate  to prevent default header filter button logic and implement custom one;
2) use ASPxPopupControl to display a Calendar and several additional filters. ASPxFormLayout is used to build a layout;
3) use the client AutoFilterByColumn method to perform filtering from the client side and  the ASPxClientGridView.PerformCallback method to pass a complex filter expression to the server to implement custom filtering;
4) process a custom callback in the ASPxGridView.CustomCallback event handler to get information about the required filter expression on the server;
5) implement the approach described in the ASPxGridView - How to programmatically change the column's filter in the FilterExpression  help article to apply a new filter.

Click on the "Model Date" column to check how this works.

MVC:
GridView - How to implement a custom HeaderFilter with a calendar for a date column

GridView - How to implement date range filtering using a custom editor in the AutoFilterRow

$
0
0

v15.2
This example is now obsolete. Starting with v15.2, we implemented a new GridViewDataColumnHeaderFilterSettings.Mode property.  Please refer to the Date Range Header Filter demo.


For older versions:


This example demonstrates how to implement date range filtering in the GridView extension.
Use the MVCxGridViewColumn.SetFilterTemplateContent  method to create a custom editor and assign a delegate method to the GridViewSettings.ProcessColumnAutoFilter property to process a custom filter expression sent from the client side.
See also:
E1990: Date range filtering in the Filter Row

Question Comments

Added By: Gustavo Sainz at: 11/11/2014 11:08:43 AM    

I can't make it to work, as the ProcessColumnAutoFilter does not trigger when settings the grid to use

 settings.CustomBindingRouteValuesCollection.Add(GridViewOperationType.Filtering, new { Controller = "ViewDate", Action = "AdvancedCustomBindingFilteringAction", key = "-1" });

Any idea how to resolve this?

Added By: Vladimir (DevExpress Support) at: 11/11/2014 10:25:08 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T171947: The ProcessColumnAutoFilter does not trigger. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Date range filtering in the Filter Row

$
0
0

v15.2
This example is now obsolete. Starting with v15.2, we implemented a new GridViewDataColumnHeaderFilterSettings.Mode property.  Please refer to the Date Range Header Filter demo.


For older versions:


This example illustrates how to specify a column's FilterTemplate by using two ASPxDateEdit controls and use them for date range filtering:
- Enter the start and end date values;
- Call the client-side ASPxClientGridView.AutoFilterByColumn method and pass the target column's FieldName and entered values as parameters;
- Handle the server-side ASPxGridView.ProcessColumnAutoFilter event;
- Check if the currently processed column (e.Column.FieldName) is the target one. If so, retrieve the passed value (e.Value) and create data range filter criteria (e.Criteria) using the approach illustrated in the Create the Custom Filter Criteria example.

See Also:
E2203: CheckComboBox filtering in the Auto Filter Row
E1950: ASPxGridView - Date auto filter
E5038: GridView - How to implement date range filtering using a custom editor in the AutoFilterRow

ASPxGridView - How to customize RowFilter in DataDateColumn and provide two ASPxDateEdit controls that allow setting a date range as a filter expression

Question Comments

Added By: Gunnar Steinn Magnússon at: 8/24/2012 9:03:41 AM    

Could you please post a suggested way to do implement this with MVCxGridView?

Added By: esa s at: 7/29/2013 6:46:41 AM    

hi, in this sample by clicking twice on the Apply button (without changing dates), the dateSelector control would not be loaded and it will cause an exception in your gridview, would you please check this ? thanks

ASPxGridView - How to customize RowFilter in DataDateColumn and provide two ASPxDateEdit controls that allow setting a date range as a filter expression

$
0
0

v15.2
This example is now obsolete. Starting with v15.2, we implemented a new GridViewDataColumnHeaderFilterSettings.Mode property.  Please refer to the Date Range Header Filter demo.


For older versions:



To achieve this goal, use GridViewColumn.FilterTemplate. Place two ASPxDateEdit controls and the "Apply" button inside the template. In the ASPxClientButton.Click event handler, create a filter expression and apply it to the grid via the ASPxClientGridView.ApplyFilter method. See the example for more details. 

Question Comments

Added By: Dhiogo Roberto at: 9/16/2014 7:50:32 AM    

I tried to use this example, but it is not working.

Added By: Luke (DevExpress) at: 9/17/2014 1:38:26 AM    Hello Dhiogo,

We've successfully fixed the issue with this example's online launch, now it works correctly. Please check it out.


Best Regards,
LukeAdded By: Dhiogo Roberto at: 9/17/2014 5:00:00 AM    

I did not notice any change. Still does not work. Only the "Example Runner" works on site.

Added By: Luke (DevExpress) at: 9/18/2014 1:21:58 AM    Hello Dhiogo,

It's pretty strange, since on my side it runs online and works perfectly (see the attached video). Would you please clarify what browser you are using and what error you faced? It would be also greatly appreciated if you provide me with your own screencast illustrating the problem (you can use the Jing tool for this purpose).


Best Regards,
Luke

ASPxGridView - Date auto filter

$
0
0

v15.2
This example is now obsolete. Starting with v15.2, we implemented a new GridViewDataColumnHeaderFilterSettings.Mode property.  Please refer to the Date Range Header Filter demo.


For older versions:


This example demonstrates how to create an ASPxComboBox filter with "today", "yesterday" and other filtering options

See Also:
CheckComboBox filtering in the Auto Filter Row
Date range filtering in the Filter Row

Question Comments

Added By: Amith Shetty 2 at: 3/24/2014 1:45:15 PM    

In the example, if i have only one record which has yesterdays day and I pick a filter of "last week", when the grid is rendered, the filter on top says "yesterday" due to the following executing first in grid_ProcessColumnAutoFilter. Is there a workaround for this?

else if (value >= start.AddDays(-1.0) &&
                value <= end.AddMilliseconds(-1.0))
                e.Value = "Yesterday";

Added By: Daniel Meltzer at: 12/17/2014 6:35:25 AM    

The sample provided via the Run Online option generates an error when selecting from the filter dropdown.

Added By: Gosha (DevExpress Support) at: 12/17/2014 11:01:12 AM    

Hello,

Yes, I see this behavior and I created a separate ticket on your behalf, T188556: The E1950 sample provided via the Run Online option generates an error when selecting from the filter dropdown, regarding this issue.

How To: Customize the Header Menu in DXTabControl


How To: Use Custom Elements in DXTabControl Tab Headers

$
0
0

In DXTabControl, you can customize content of tab item headers using the HeaderTemplate property. This template's DataContext contains an object specified in the Header property. So, you can use an empty binding to bind to the header:

[XAML]
<TextBlockText="{Binding}"/>

You can also customize the Glyph representation using the GlyphTemplate property.

(OBSOLETE) How to export the GridDashboardItem item data to Excel from a web solution

$
0
0

Udpate: The ASPxDashboardViewer version 15.2 supports the Export To Excel functionality out of the box: Exporting Dashboard Items

In this example, you will find how to implement server-side export of the GridDashboardItem data from an ASP.NET solution using the report suite. The export is performed in three steps:
1. We request data displayed in a specific dashboard item using a client-side script provided in the T182186: How to get visible data from a certain dashboard item on the client side and process it on the server side example and send this data to the server in the form of a JSON string.
2. The JSON string is parsed on the server side. Based on the retrieved data, we generate a report containing a simple table.
3. Finally, it is necessary to export the report to an Excel document and write this document to the response. It is possible to use the same approach to export the resultant report to other file types. 

(OBSOLETE) How to export GridDashboardItem to Excel using an intermediate report (WinForms)

$
0
0

Udpate: The Dashboard Suite version 15.2 supports the Export To Excel functionality out of the box: Printing and Exporting
This example demonstrates how to fetch data from the GridDashboardItem placed in the DashboardViewer class instance. To get data from the item, the DashboardViewer.GetItemData method is used. Please look at the static GridDashboardItemToDataTableHelper class. With a MultiDimensionalData class instance, it is possible to create columns (see the CreateColumnsByGridDashboardItem method) and fill a DataTable (see the AddRowsByGridDashboardItem method). This table will be further used in a report to perform the export. I used the report from the How to export the GridDashboardItem item data to Excel from a web solution example.

How to separate data between employees and managers of different departments using security permissions

$
0
0

Scenario
This example demonstrates how to use the new security system to implement the following security roles:

- Users (Joe, John) can view and edit tasks from their own department, but cannot delete them or create new ones. They also have readonly access to employees and other data of their own department.

- Managers (Sam, Mary) can fully manage (CRUD) their own department, its employees and tasks. However, they cannot access data from other departments.

- Administrators (Admin) can do everything within the application.
All users have empty passwords by default.


Steps to implement

1.Permissions at the type, object and member level (with a criteria) are configured in the MainDemo.Module/DatabaseUpdate/Updater file. Take special note that for building a complex criteria against associated objects, the JoinOperand together with the built-in CurrentUserId and IsCurrentUserInRole criteria functions. For greater convenience, strongly typed criteria for permissions are accompanied with their string representation.

2. The SecuredObjectSpaceProvider is used in the CreateDefaultObjectSpaceProvider method of the XafApplication descendants located in the WinForms and ASP.NET projects.

3. Permission requests caching is enabled via the IsGrantedAdapter.Enable method in the MainDemo.Module\MainDemoModule.xx file (see the T241873 ticket for more details).

4. The Department, Employee and EmployeeTask classes are implemented in the MainDemo.Module/BusinessObjects folder. To quickly understand relationships between involved business classes, their class diagram is attached.


IMPORTANT NOTES
1. 
See also the functional tests in the MainDemo.EasyTests folder for more details on the tested scenarios.
2.
For versions older than v15.2.5, be aware of the issue described in the Security - The "Entering state 'GetObjectsNonReenterant'" error may occur while saving data if a permission criteria involves a collection property thread.
3.The State of the New Security System

Question Comments

Added By: Raoulw at: 2/11/2013 2:02:04 PM    

This is a great sample. There is one error, or it is not clear in the description. 'Users (Joe, John) can do everything with their own tasks and can also view data of their own department;' implies that Joe has read only access to Mary's tasks, which is not true. The code below fixes that.

Raoul.

                SecuritySystemObjectPermissionsObject canSeeTasksOnlyFromOwnDepartmentObjectPermission = ObjectSpace.CreateObject<SecuritySystemObjectPermissionsObject>();
                //canSeeTasksOnlyFromOwnDepartmentObjectPermission.Criteria = "AssignedTo.Department.Oid=[<Employee>][Oid=CurrentUserId()].Single(Department.Oid)";
                canSeeTasksOnlyFromOwnDepartmentObjectPermission.Criteria = new BinaryOperator(new OperandProperty("AssignedTo.Department.Oid"), joinEmployees, BinaryOperatorType.Equal).ToString();
                canSeeTasksOnlyFromOwnDepartmentObjectPermission.AllowNavigate = true;
                canSeeTasksOnlyFromOwnDepartmentObjectPermission.AllowRead = true;
                canSeeTasksOnlyFromOwnDepartmentObjectPermission.AllowWrite = false;
                canSeeTasksOnlyFromOwnDepartmentObjectPermission.AllowDelete = false;
                canSeeTasksOnlyFromOwnDepartmentObjectPermission.Save();
                employeeTaskPermissions.ObjectPermissions.Add(canSeeTasksOnlyFromOwnDepartmentObjectPermission);

Added By: Dennis (DevExpress Support) at: 7/4/2013 7:31:27 AM    

Thanks for your update, Raoul!

Added By: Konstantin B at: 10/17/2013 4:47:01 AM    

I'm tried to apply solution for bug fixing "Security - The "Entering state 'GetObjectsNonReenterant error may occur while saving data if a permission criteria involves a collection property" to this example, but unsuccessfully - always get GetObjectsNonReenterant exception.
Could you please supply the project how can fix it for the current example?

Thanks

Added By: Dennis (DevExpress Support) at: 10/21/2013 6:32:14 AM    

Please track https://www.devexpress.com/Support/Center/Question/Details/Q287727 for any updates on this problem. Thanks!

How to merge documents into a single PDF

$
0
0

This example illustrates how to use PDF Document Processor  for merging pages of two separate PDF files into a single PDF file.

The Universal Subscription or an additional Document Server Subscription is required to use this example in production code. Please refer to the DevExpress Subscription page for pricing information.

Question Comments

Added By: Adriana Monterrubio at: 11/6/2014 11:52:24 AM    

Is there a way to merge two pages in only one page?

Added By: Elliot (DevExpress Support) at: 11/7/2014 1:28:01 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T170308: Is there a way to merge two pages in only one page?. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Viewing all 7205 articles
Browse latest View live


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