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

Web Report Designer - How to open a report with an untyped data set as a data source

$
0
0
Currently, strongly typed DataSets are serialized, while untyped are not. 

Obviously, this behavior produces incorrect results if you save/load a report layout to/from XML.

Since the Web Report Designer works with the XML report representation, incorrect results may be also produced when loading a report which an untyped data set as a data source.

To resolve this, we need to serialize an untyped data source.
To do so, implement a custom serializer which implements the DevExpress.XtraReports.Native.IDataSerializer interface and use the XML-serialization capabilities exposed by the DataSet class to serialize/deserialize this data set as follows. 

In the IDataSerializer.Serialize method, serialize a DataSet into XML through the DataSet.WriteXml (or DataSet.GetXml) method.
In the IDataSerializer.Deserialize method, create a new DataSet instance and populate it from a properly formatted XML stream by using the DataSet.ReadXml method.

How to use the built-in caching functionality of the ASP.NET MVC Document Viewer

$
0
0

This example illustrates how to make the DocumentViewer store its document on the client between postbacks.

When the Document Viewer extension performs a callback to the server (for example, when a page is changed), the report document is restored from the cache. So, it is not necessary to recreate a report document and data is not retrieved from the database. The Document Viewer manages a cached document by using the CacheReportDocument and RestoreReportDocumentFromCache delegates.

Note that in case of using this approach, it is necessary to move your report data binding code to its DataSourceDemanded event handler.

 

To learn how to accomplish this task in ASP.NET WebForms, see the following code example: How to use the caching functionality of the Document Viewer

How to serialize a report to XML with an untyped data set as a data source

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

Document Layout API - Practical usage

$
0
0

This example demonstrates how RichEditControl's DocumentLayout API can be used to collect information about a currently clicked document element (as well as its parent elements):
Layout API

Depending on the type (text block, image, table cell, textbox, etc.) of a clicked element, the following information can be analyzed:
content, content bounds, position on a page, page bounds, current page index, a number of images/textboxes on a page, common text blocks count, etc.


In this example, different approaches are used to get layout information about a current element:
- Use the DocumentLayout.GetElement and DocumentLayout.GetElement[T] methods;
- Use the LayoutIterator class;
- Use a custom LayoutVisitor descendant.

To get layout information about the current element, set the caret inside a text block or table cell (or select an image) and click the "Analyze a current document layout" button.

How to use GridLookup in Custom Data Binding mode

How to sort report data in Print Preview by using a drop-down menu

$
0
0
This example demonstrates how to implement a drop-down menu that allows you to choose the sort order for a table column and then sort a table.
This approach implies that you initially assign a special value to the Tag property of the XRTableCell that represents a header cell.

To initiate sorting for a column, assign the "Sort_<FieldName>" string to Tag.
 
You can also implement a 'Clear All' label. To do so, assign the "Clear_Sort" string to the XRControl.Tag property.

Please note that with this approach, we do not recommend using the standard approach which implies using a band's SortFields collection.

See also:
How to: Sort a Report in the Preview
How to sort a report in preview

How to Add Unbound Fields

$
0
0

The following example shows how to add unbound fields to the ASPxPivotGrid.

The 'DiscountAmount' unbound field's values are calculated using the PivotGridFieldBase.UnboundExpression property, while the 'PriceWithDiscount' unbound field is populated by handling the ASPxPivotGrid.CustomUnboundFieldData event.

See Also:
How to calculate custom values based on other field values
Unbound Data


How to use two-way data-bound ASPxGridLookup in edit form of ASPxGridView to edit data

$
0
0

This example shows how to use a two-way data-bound ASPxGridLookup in the edit form of ASPxGridView to update or insert new data.

Question Comments

Added By: Rabab Siblini at: 7/22/2015 12:43:08 AM    

Hello,
how can I implement this with a row with group Index? as it works only for a non group grid

Web Report Designer - How to use the custom serializer class (IDataSerializer) to serialize the XPO data source to make it visible in the web report designer

$
0
0

This example demonstrates how to use the custom data source component serializer class that implements the IDataSerializer interface to serialize a report's data source component. This approach is actual when you are displaying a report that uses the data source component that cannot be serialized by the report (for example, XPCollection, DataSet (untyped), IList). The Web Report Designer stores only the report definition, so if the data source component is not serialized, this component cannot be restored on the callbacks. As a result, the designer's Field List and Preview will be empty.
Note that such data source components as SqlDataSourceEFDataSourceObjectDataSource and Typed DataSets are serialized out-of-the-box, so it is not necessary to use this approach in case of using these components.

Use the following steps to serialize your report's data source component:
1. Create a custom data source component serializer class that implements the IDataSerializer interface. Implement this interface's methods to save (in the Serialize method) and restore (in the Deserialize method) your data source component from the string.
2. Register your custom data source component serializer class when your application is started. For example, use the Application_Start event in the application's Global.asax.cs file for this purpose:

[C#]
protectedvoidApplication_Start(objectsender,EventArgse){SerializationService.RegisterSerializer(XPCollectionSerializer.NAME,newXPCollectionSerializer());}

3. Assign the custom data source component serializer name (that you have registered in the previous step) to your report as demonstrated below:

[C#]
XtraReportreport=newCategoriesReport();report.Extensions[SerializationService.Guid]=XPCollectionSerializer.NAME;

You should do that before opening you report in the Web report designer.


Important Note: This approach will work only for XML serialization. So, if you want to save the report along with the serialized DataSource, use the XtraReport.SaveLayoutToXml method to save the report's definition.


FAQ:
How to implement the custom serializer class (IDataSerializer) to serialize the DataSet data source?
Please refer to the to the following KB article to learn how to do that: How to serialize a report to XML with an untyped DataSet as a data source.

How to load a PDF document from a stream

$
0
0
The following example illustrates how to load a document into the PDF Viewer from a Stream at runtime.

MVC DocumentViewer extension - Creating a multi-select parameter

$
0
0

NOTE Starting with version 15.1 the multi-select parameters for our reporting suite are available out of the box. See the Parameters Overview > Using Parameters > Multi-Value Parameters help topic for more details.


This example demonstrates how to use a custom editor for the report's parameter to implement a multi-select parameter. The TokenBox extension is used as a multi-select parameter editor.


The main idea of this approach is to use a report's parameter to pass a string that contains CategoryIDs separated by the '|' character to the report. Then on the report's DataSourceDemanded event handler the report's DataSource is populated based on the parameter value.
The approach demonstrated in the DocumentViewer - How to customize a report parameter editor in MVC application code example is used to customize the DocumentViewer parameter editor.

See also:
MVC DocumentViewer - How to create a custom CheckedComboBox parameter editor with the "Select All" functionality for a report
ASPxDocumentViewer - How to customize a parameter editor (Creating a multi-select parameter)

ASPxDocumentViewer - How to customize a parameter editor (Creating a multi-select parameter)

$
0
0

NOTE Starting with version 15.1 the multi-select parameters for our reporting suite are available out of the box. See the Parameters Overview > Using Parameters > Multi-Value Parameters help topic for more details.


This example demonstrates how to use a custom editor for the report's parameter to implement a multi-select parameter. The ASPxTokenBox control is used as a multi-select parameter editor.


The main idea of this approach is to use a report's parameter to pass a string that contains CategoryIDs separated by the '|' character to the report. Then on the report's DataSourceDemanded event handler the report's DataSource is populated based on the parameter value.
The ASPxDocumentViewer.CustomizeParameterEditors event handler is used to customize the report's parameter editor: assign a required editor (ASPxEditBase class descendant) to the e.Editor property, and specify its Init event. Then use this Init event handler to initialize your custom parameter editor and bind it to the data.

See also:
MVC DocumentViewer extension - Creating a multi-select parameter
MVC DocumentViewer - How to create a custom CheckedComboBox parameter editor with the "Select All" functionality for a report

How to access API of underlying widgets in the MVC Viewer

$
0
0
This example demonstrates how to customize client widgets used to visualize data within dashboard items at runtime using ASPxClientDashboardViewer's API.
The following options are changed:
- Highlighting of the hovered grid row is enabled in the underlying dxDataGrid in the ItemWidgetCreated event handler.
- A standard tooltip that is invoked when an end-user hovers over a chart series point is disabled. You can invoke a tooltip by clicking the required label on the argument axis. The argumentAxisClick event is used for this purpose. Subscription and unsubscription to/from the argumentAxisClick event are performed in the ItemWidgetCreated and ItemBeforeWidgetDisposed event handlers respectively.
- A pie legend is shown for the underlying dxPieChart.
Question Comments

Added By: Mariusz Bialobrzeski at: 7/22/2015 1:27:47 PM    

Hi,

I have a dashboard in ASP.Net MVC project. Inside the dashboard I have cards, chart, gauge and range filter dashboard items. I added the js file to the Scripts folder and changed the partial view. When I run the program I do not see any changes on the dashboard. Do I need to do something else to make it work?
Thanks.

How to override a command in the Document Preview (DocumentPreviewControl) - Custom export

$
0
0
This example demonstrates how to override a command in the Document Preview.

To override a command in DocumentPreviewControl, create a DocumentPreviewControl descendant and use either of the following approaches.
1. Handle a command by overriding the corresponding method of DocumentPreviewControl. E.g., handle the Export command by overriding  the CanExport and Export methods.

2. Implement a custom DocumentCommandProvider to override a required command. 

This example demonstrates how to override (disable) the Export To PDF Document Preview command by using both these solutions.

NOTE
DocumentPreviewControl is available starting with version 15.1. For an older document preview, use the approach given at How to override existing export (send) command handlers in the DocumentPreview toolbar.

How to implement setting custom margins in ASPxSpreadSheet

$
0
0

This code example demonstrates how to implement setting custom margins in the ASPxSpreadSheet.

To test the functionality, choose menu item Margins - Custom Margins, set preferable values and open a document preview using File - Print menu.

How to change SummaryDisplayType via the context menu

How to implement a service to manage the process of worksheet cell calculation

$
0
0
This example illustrates the use of the service which implements the DevExpress.XtraSpreadsheet.Services.ICustomCalculationService  interface and allows to manage the process of worksheet calculations.
The application creates log entries when worksheet calculation starts and finishes, when cell calculation begins and ends, when a cell with the circular reference starts and finishes its calculation.
Cells containing circular reference are indicated by drawing a red box within the cell.



How to load a PDF document from the Stream

How to change the LayoutGroup's size proportionally

$
0
0

This example contains LayoutControl and LayoutGroup descendants. The ExtraLayoutGroup's LayoutItemSize property is universal and contains group Width for horizontal parent orientation or Height for vertical orientation.

Viewing all 7205 articles
Browse latest View live


Latest Images

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