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

How to sort data in server mode using the CustomServerModeSort event

$
0
0
This example demonstrates how to implement a custom sorting algorithm by handling the CustomServerModeSort event. The "Month" column field is sorted by the "Produce" row using the cross area key, and the "Category" field is sorted directly by the 1996 year.

How to sort data in server mode using the CustomServerModeSort event

$
0
0
This example demonstrates how to implement a custom sorting algorithm by handling the CustomServerModeSort event. The "Month" column field is sorted by the "Produce" row using the cross area key, and the "Confections" field is sorted directly by the 1998 year.

Custom GridControl - How to hide particular GroupRow Headers & Footers

$
0
0

This example demonstrates how to implement a GridControl descendant which allows hiding the header and footer for groups with an empty group row value.

How to create a report dynamically in the WinForms application

$
0
0

This example illustrates how to generate a report dynamically.

For further information please refer to the corresponding article : How to create a report dynamically

Question Comments

Added By: Daniel Kaminski at: 7/7/2015 8:52:01 AM    

Please update this project to .NET 4.0. It will not compile in .NET 3.5

How to use OData (WCF Data Services) to provide data for a report

$
0
0
At the moment, XtraReports cannot connect to an OData data source directly. 

Our reporting tools, however, are data sources agnostic. 
They support data source of different types, including .NET data providers, lists (implementing the System.Collections.IList, System.ComponentModel.ITypedList, or System.ComponentModel.IBindingList interfaces), and XML data sources. To learn more, refer to Data Binding Approaches.

So, to provide report data through the OData service, get IList data from the OData Service and then pass it to a report. Here are implementation details.

1. Add the OData Service Reference to your project. Now, the OData service context is registered in the application. 
2. Create a data model from the OData Service context. This data model will retrieve data from the OData service and return IList data. 
3. Bind a report to this data model through the ObjectDataSource component.

How to get rid of the space reserved for images in the TreeListNode when a certain TreeListNode has no images

$
0
0

When the TreeList.SelectImageList or TreeList.StateImageList properties are assigned, each TreeListNode has an indent to draw these images, even if the TreeListNode.SelectImageIndex or TreeListNode.StateImageIndex properties are set to -1.

In a situation when this behavior is undesirable, it's possible to create a custom TreeList descendant, and change it by overriding the TreeListViewInfo.GetDataBoundsLocation method.

Question Comments

Added By: Daniel Parsons at: 7/7/2015 12:06:05 PM    

Corrected code as follows:
protected override void CalcStateImage(RowInfo ri)
       {
           base.CalcStateImage(ri);
           if (Size.Empty != RC.StateImageSize && -1 == ri.Node.StateImageIndex)
               ri.StateImageLocation.X -= RC.StateImageSize.Width;
       }

GridView - How to specify a custom EditForm Template

$
0
0

This example illustrates how to:
- Specify a custom EditForm Template via the GridViewSettings.SetEditFormTemplateContent method;
- Define the UploadControl Extension inside this template for uploading files when creating/editing a row (Note that UploadControl should be wrapped with a form to be able to post a selected file);
- Edit the in-memory datasource.

See Also:
E3530: How to bind GridView with standard in-memory data sources (DataTable, List<T>)
E3983: GridView - How to edit in memory data source

Question Comments

Added By: Hari haran 3 at: 7/7/2015 10:53:19 PM    

awesome

ToggleSwitch - How to modify size of thumb image and backing image

$
0
0
This example illustrates how to modify the size of ToggleSwitch editor's thumb and backing images

How to override commands in Print Preview - Custom export

$
0
0

This example demonstrates how to override the Print Preview command that exports a report document to an image file. This can be useful, for example, if it's necessary to silently save a report to the predefined location on a disk, using the predefined image format settings, and if no interaction with an end-user is required.

To implement this task you should handle the XtraPrinting.PrintingSystemCommand.ExportGraphic command in the Print Preview form. Note that to prevent the standard exporting procedure from being called you just need to set the handled property to true.

You may use this approach to override any other standard actions which can be performed by an end-user in the Print Preview form. To get the full list of these commands, see the XtraPrinting.PrintingSystemCommand enumeration's description.

MvvmExpenses Sample Application

$
0
0
This is a sample application, created in MVVM Tutorials section. Follow this link to see these lessons.

To log in, use one of the following credentials:
Administrator - admin
John - qwerty
Mary - 12345
Guest - (no password set)
Question Comments

Added By: Hedi Guizani at: 6/17/2015 12:58:21 PM    

Can we have the same exemple but using xpo please

Added By: Alisher (DevExpress Support) at: 6/18/2015 10:06:09 AM    

Hi Hedi,

At present, our scaffolding wizard does not support XPO. Once we support this functionality, we will inform you. We don't have plans to modify sources of our tutorials including this example, however, be sure that once we support XPO with a scaffolding wizard, you'll be able to generate correct view models for working with data.

Added By: Hedi Guizani at: 6/18/2015 12:34:35 PM    

Fair enough,
The only thing I may ask is how soon xpo will be supported by the scaffolding wizard?
I m gone through the learning curve of xpo thinking devx will favore if over EF but it seems it is not the case, sometimes I m really lost without a clear road map, XAF or Mvvm, XPO or EF, wf or wpf, mvc or extreme, I think .net roadmap is unclear enough so guys please just show as the path and we will follow you ;)

Added By: Alisher (DevExpress Support) at: 6/19/2015 7:38:52 AM    

Hedi,

I am afraid I can't provide you with any ETA on when we will implement this functionality. We will certainly inform you once it is implemented. As for the roadmap, we don't have a Roadmap for 2015 and will unlikely generate any future road maps. I suggest that you check Vache's comment in the Is there any public roadmap for 2015.1 available? ticket.
Let me know if you have additional questions.

How to display data which is being updated on another thread

$
0
0

Let's suppose that your data is being updated on another thread, by the timer in this example. You should take a special action to correctly reflect those changes in the grid - wrap them inside BeginDataUpdate/EndDataUpdate calls.

When using the MVVM pattern, it is not possible to call grid's methods directly from the view model. Your view model can provide additional events to expose such changes of its state to the view. There are OnAsyncProcessingStarted and OnAsyncProcessingCompleted events in this example. Now you can handle these events in the view and force the grid to stop/start listening for data updates before/after asynchronous data modifications.

Please note even though this approach requires several code lines in View's code-behind, ViewModel in this situation is completely independent from GridControl. Thus, this approach conforms the MVVM pattern.


UPDATED:


After we introduced Services, the same task can be implemented by creating a custom service (How to create a Custom Service). This service will have access to the GridControl in the View, and will contain the required BeginUpdate and EndUpdate methods. In these methods, GridControl’s BeginDataUpdate and EndDataUpdate methods will be called.

Starting with v13.1.4, this example illustrates this approach.

 

How to allow columns to fit their content after changing or modifying GridControl's ItemSource

$
0
0

This example demonstrates how to allow columns to fit their content after changing or modifying GridControl's ItemSource.
To provide this capability in this sample, we iterate through GridControl's ItemsSource collection and subscribe to the PropertyChanged event of each item in this collection. Then we subscribe to GridControl's ItemsSourceChanged event, get GridControl's ItemsSource collection and subscribe to its CollectionChanged event. When one of these events is raised, we call TableView's BestFitColumns method. Please note that GridControl's ItemsSource collection must support the INotifyCollectionChanged interface and each item in this collection must support the INotifyPropertyChanged interface.


UPDATED:

All the required event subscriptions and the corresponding event handlers are encapsulated into the custom Behavior class descendant. 

Question Comments

Added By: Quentin Suckling at: 5/5/2015 6:24:34 PM    

Hi guys,

When the view is closed and the grid unloaded, will the CollectionChanged and/or the ItemsSource events get fired?

If not, I'm guessing it would need to subscribe to the Unload event and then unsubscribe to the PropertyChanged event otherwise it won't be GC'd?

Cheers,
Quentin

Added By: Ivan (DevExpress Support) at: 5/6/2015 12:26:02 AM    

You are correct, the current implementation can lead to memory leaks since we don't unsubscribe from the PropertyChanged/CollectionChanged events. You can unsubscribe from them in the Unloaded event handler. Feel free to contact us if you face issues with this approach.

How to create a custom action type with a custom control (BarCheckItem), associated with it

$
0
0

This example demonstrates how to represent an action via the BarCheckItem. For this purpose, an ActionBase descendant (CheckableSimpleAction) is implemented. This is done because it is required to save the checked state of the action. CheckableSimpleAction uses a custom action item (CheckActionItem), which represents it in the UI via a BarCheckItem. Action item is a connector between the abstract entity Action and a particular UI element. When the form's menu is created, XAF creates action items for all actions placed to this form via action containers. This operation is performed by the BarActionItemsFactory and the ActionControlsSiteController. Since we have implemented a custom action type, it is required to implement a custom BarActionItemsFactory to assign an appropriate action item to actions of this type. The custom BarActionItemsFactory is registered via the custom factory provider (MyBarActionItemsFactoryProvider).
Note that in most cases, it is not required to implement a custom action and action item. It is sufficient to customize the existing action item via the BarActionItemsFactory.CustomizeActionControl event. This approach is demonstrated in the How to: Customize Controls Associated with an Action topic.
An example for ASP.NET is available here: How to create a custom action type with a custom control in Web

Note for versions 14.2, 15.1: Currently, custom action types are not supported in our new form templates. Refer to the How to add a checkbox to the toolbar ticket to learn how to add a BarCheckItem to new templates.

How to invoke the default Appointment Recurrence dialog from a custom Edit Appointment form

$
0
0

This example demonstrates how to invoke the default Appointment Recurrence dialog from your own custom Edit Appointment form.

Question Comments

Added By: Andres Cruz at: 7/8/2015 11:43:12 AM    

This example does not work in 15.1.4, does not show the customized form

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 CustomCellDisplayText or CustomCellValue event, as shown in the example project.

Note that it is also possible to access cell corresponding to a specific Field Value instead of the next/previous one. This functionality is demonstrated in the Get summary values for previous period while calculating the current one example.


How to extract XtraReport scripts source code generated by its internal script manager

$
0
0

This example demonstrates how to extract a report scripting code by using the .NET Reflection mechanism so you can review the full scripting code. 

IMPORTANT NOTE

Starting with version 9.3, the Scripts tab was introduced (find it both in the Visual Studio IDE Report Designer and the End-User Designer) to provide the quick centralized access to all scripts that exist within a report. See Scripting Overview for further information. You can debug scripting code as described here: Using Visual Studio for Script Debugging in XtraReports

PopupControlContainer - How to draw a custom string in popup control container's footer

$
0
0
This example illustrates how to draw a custom string in popup control container's footer

How to print the detail report band content for a data-bound report multiple times

$
0
0
If a report is unbound, you can specify how many times the Detail band content is printed through the XtraReport.PrintOptions.DetailCountOnEmptyDataSource property.

If a report is data bound, you can limit the number of times the Detail band is printed by using the DetailCount property.

Please note that the DetailCount property is designed to specify the maximum number (i.e., the limit) of times the Detail band is printed. In other words, if a data source contains one record, we cannot print it more than one time by using the DetailCount property.
We need to use the solution illustrated by this example. It demonstrates how to repeat a data source record depending on a value taken from another field. To achieve this, add an unbound DetailReportBand and control the number of copies using its ReportPrintOptions.DetailCountOnEmptyDataSource property.

How to create a custom XtraMessageBox with the extended functionality

$
0
0

This example demonstrates how to create a MessageBox with an extended functionality. For this, create MyXtraMessageBox class descendant that is inherited from the XtraMessageBox class and uses the XtraMessageBoxArgs class - a MyXtraMessageArgs descendant which contains properties to customize the XtraMessageBox behavior. 
- ShowCountDown. If this property is true, the message box title will show you how many seconds are left before the timeout. When the countdown is over, the title will show its usual value.
- ShowNextTime. This property allows you to show a CheckBox on your message form. When you close the form, the result will be saved in the ShowMessageNextTime property of MyXtraMessageArgs and you can use this value later.
- DisableButtons. If this property value is true, all buttons except for "Cancel" will be disabled on the form.
- DisableCancel. This property gives you an opportunity to disable the "Cancel" button on the form.
- AutoClose. If you want to close your form, after the countdown is over, set this property to true. Also, you need to define the value of the AutoCloseResult property. This property shows what value will be received from the MyXtraMessageBox.Show method if the form is automatically closed.
- Center. If this property value is true, the MessageBox will be center aligned against its parent form.
- Timeout. This property sets the timer for the AutoClose and ShowCountDown properties in seconds. Its value should be greater than 0, otherwise, these properties will be unavailable.
- Buttons. This property specifies what buttons will be available on the form.
- Icon. This property specifies the MessageBox icon.

Question Comments

Added By: Rainer Leonardy at: 7/9/2015 11:40:33 AM    

if you run the project you will get an  error "System.NullReferenceException"

you will get the error in the c# and the vb version

Public Shared Function GetDialogResultsFromButtons(ByVal buttons As MessageBoxButtons) As DialogResult()
           Dim xtraMessageBoxInfo As MethodInfo = GetType(XtraMessageBox).GetMethod("MessageBoxButtonsToDialogResults", BindingFlags.Static Or BindingFlags.NonPublic)
 error --->         Return DirectCast(xtraMessageBoxInfo.Invoke(Nothing, New Object() { buttons }), DialogResult())
       End Function

How to integrate the Web Report Designer into a web application

$
0
0

This example demonstrates how you can integrate the Web Report Designer into your web application. The application contains a simple report catalog, allowing you to add, delete, and edit reports whose layout data is stored in a custom data storage (i.e., an MDB database).

 Additionally, this example demonstrates how you can add custom commands to the report designer menu at runtime to provide better integration with your application. In the example, the custom Save&Close menu command is introduced, which redirects you to the catalog page after saving the report.

 
See also:
T190370: How to integrate the Web Report Designer into an MVC web application
T227679: ASPxReportDesigner - How to create an ASP.NET End-User reporting application with the filesystem report storage managed by the ASPxFileManager control

Question Comments

Added By: Ruslan Novokhatskiy at: 7/10/2015 6:41:00 AM    

Can't understand. Where u take report.save()? what is report and what is method save()? Is any reference of JS objects and methods?

Added By: Vasily (DevExpress Support) at: 7/10/2015 7:54:31 AM    Hello Ruslan ,

To process your recent post more efficiently, I created a separate ticket on your behalf: T265741: How to integrate the Web Report Designer into a web application. 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