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

How to resize GaugeControl on printing/exporting

$
0
0

This example illustrates an approach of including a GaugeControl image into a document generated via SimpleLink (DXPrinting).

In the example, a gauge's image is obtained via the RenderTargetBitmap.Render method. Before rendering, special code is executed to resize the control based on the target documents requirements. 


How to create a custom exporter for the PivotGridControl by using the XtraReport suite (This exporter provides the AutoRowHeight, BestFit and FitToPage features)

$
0
0

This example illustrates how to dynamically create a custom report based on PivotGridControl content.
It also implements the following suggestions:
S130430: Support word wrap when printing and exporting
S91257: Utilize a Line color when printing
AS9011: Print row headers on every page on export/printing
and the S18650: Add an event that allows to provide custom size for field values (MeasureFieldValue, or so)  suggestion for printing facilities.

See Also:
How to create a custom exporter for the ASPxPivotGrid control by using the XtraReport suite (This exporter provides the AutoRowHeight, BestFit and FitToPage features)

Question Comments

Added By: Darshan Bansal at: 5/21/2013 11:50:18 AM    

Hello,

We are trying to implement this in our pivotgrid... we are getting an error under method FillDatasetColumns. We are getting an object reference not set to an instance of an object at line "tempColumnText +=pcea.GetFieldvalue(field).ToString()+ " | " Do not know what would be causing this??

Added By: AntonyC at: 7/31/2013 2:30:20 AM    

Would this allow for the export of a chart linked to the PivotGrid control?

Added By: Ana Claudia Tavares Cardoso at: 9/11/2014 5:50:30 PM    

Boa Noite

I have the same problem, however, my report should contain three PivogridControl. According to this example does not work, have any suggestions?

Tank

Added By: John (DevExpress Support) at: 9/12/2014 4:41:16 AM    Hi Ana,
It seems that you have already asked a similar question in our support center: E2231 - How to create a custom exporter for the PivotGridControl by using the XtraReport suite. Lets continue the conversation there.

How to create a custom exporter for the DXPivotGrid control by using the XtraReport suite (This exporter provides the AutoRowHeight, BestFit and FitToPage features)

$
0
0
This example illustrates how to dynamically create a custom report based on PivotGridControl content. This report contains a plane table representing pivot grid data. 

How to export the AcroForm data

$
0
0

This example shows how a PDF document with the AcroForm data (interactive forms) can be exported either to the XML or FDF format.

How to import the AcroForm data

$
0
0
This example demonstrates how you can import the AcroForm data  (interactive forms) either from XML or FDF format  to a PDF document.

Custom callback based implementation of cascading comboboxes (in a detail Grid)

$
0
0

This demo is based on the sample provided in example E1362. It uses custom callbacks to implement cascading comboboxes in a detail GridView. Two comboboxes edit two database fields. The value list in a depended control is filtered based on the value selected in master control.

Question Comments

Added By: Greg Gagliano at: 8/4/2015 9:23:47 AM    

I cannot get this example to work properly. I have followed it exactly using my own data. In the display grid (not in edit mode) the GridViewDataComboBoxColumn for Category2ID is displaying the ID value instead of the Textfield value even though the TextField and ValueField is set properly and both fields are returned by the data source. Also, when editing,  the Category1ID Combobox never allows selection to occur and Category2ID is not updated.

Added By: Larry (DevExpress Support) at: 8/4/2015 11:57:49 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T274803: E2156 example - GridViewDataComboBoxColumn shows thу value instead of the text. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to clone a persistent object

$
0
0

Scenario

In this example, we create a CloneIXPSimpleObjectHelper class that will be used to clone the provided persistent object. 

Steps to implement

1. Implement the CloneIXPSimpleObjectHelper class as shown in the CloneIXPSimpleObjectHelper.xx file. This class uses persistent object metadata to create a copy of the provided persistent object. 
The Clone method has several constructors that allow you to specify the target Session and determine whether object synchronization is required or not. If the synchronize parameter is set to true, reference properties are only cloned if the reference object does not exist in the target Session. Otherwise, the existing object will be reused and synchronized with the source. Set this property to false if the target Session does not contain an object of the source.

2. Create a Form that will use the ListBox control to display the result of creating and cloning persistent objects. See the code of the Form class in the Form1.xx file.


As a result, the following output will be shown:



See also:
How to get a list of a persistent object's properties
Should I use XPO to transfer data between databases?

Question Comments

Added By: Sigurd Decroos at: 1/8/2013 5:48:41 PM    

There's a little catch with this code. Primary Keys are changed, so it doesn't make a real clone, but a copy. You have to change the code a bit so the primary key gets synced too if needed.

Added By: Mr292 at: 2/16/2013 12:45:27 PM    

I refactored some in order to replicate to different databases as well as to different assemblies in the other database. I came about this requirement because I wanted to remodel my DOM and did not want to have to manually do a lot of data imports.

    public class CloneIXPSimpleObjectHelper
    {
        /// <summary>
        /// A dictionary containing objects from the source session as key and objects from the
        /// target session as values
        /// </summary>
        /// <returns></returns>
        Dictionary<object, object> clonedObjects;
        Session sourceSession;
        UnitOfWork targetSession;

        /// <summary>
        /// Initializes a new instance of the CloneIXPSimpleObjectHelper class.
        /// </summary>
        public CloneIXPSimpleObjectHelper(Session source, UnitOfWork target)
        {
            clonedObjects = new Dictionary<object, object>();
            sourceSession = source;
            targetSession = target;
        }

        /// <summary>
        /// Initializes a new instance of the CloneIXPSimpleObjectHelper class to Clone to Different DB.
        /// </summary>
        public CloneIXPSimpleObjectHelper(Session session, string connstring)
        {
            UnitOfWork NewUOW = new UnitOfWork(
                XpoDefault.GetDataLayer(connstring, DevExpress.Xpo.DB.AutoCreateOption.SchemaAlreadyExists));

            clonedObjects = new Dictionary<object, object>();
            sourceSession = session;
            targetSession = NewUOW;
        }

        /// <summary>
        /// Initializes a new instance of the CloneIXPSimpleObjectHelper class to Clone to Different Assembly / DB.
        /// </summary>
        public CloneIXPSimpleObjectHelper(Session session, string connstring, System.Reflection.Assembly assembly)
        {

            var dict = new ReflectionDictionary();
            foreach (var item in assembly.GetTypes())
            {
                    if (item.IsSubclassOf(typeof(XPBaseObject)))
                        dict.CollectClassInfos(item);
            }
    
            UnitOfWork NewUOW = new UnitOfWork(
                XpoDefault.GetDataLayer(connstring, dict,
                DevExpress.Xpo.DB.AutoCreateOption.SchemaAlreadyExists));

            clonedObjects = new Dictionary<object, object>();
            sourceSession = session;
            targetSession = NewUOW;

        }

        public void Commit()
        {
            targetSession.CommitTransaction();
           
        }

        public T Clone<T>(T source) where T : IXPSimpleObject
        {
            return Clone<T>(source, targetSession, CloneMethod.IgnoreIfExistsInDesitnation);
        }
        public T Clone<T>(T source, CloneMethod sync) where T : IXPSimpleObject
        {
            return (T)Clone(source as IXPSimpleObject, targetSession, sync);
        }

        public object Clone(IXPSimpleObject source)
        {
            return Clone(source, targetSession, CloneMethod.IgnoreIfExistsInDesitnation);
        }
        public object Clone(IXPSimpleObject source, CloneMethod sync)
        {
            return Clone(source as IXPSimpleObject, targetSession, sync);
        }
        public object Clone(IXPSimpleObject source, Session targetSession, CloneMethod sync)
        {
            return Clone(source as IXPSimpleObject, targetSession, sync);
        }
        public T Clone<T>(T source, UnitOfWork targetSession, CloneMethod sync) where T : IXPSimpleObject
        {
            return (T)Clone(source as IXPSimpleObject, targetSession, sync);
        }
        public object Clone(XPBaseObject obj, Type targetType, CloneMethod sync)
        {
            return Clone(obj, targetSession, targetSession.GetClassInfo(targetType), sync);
        }

        public enum CloneMethod
        {
            TransferOnly,
            Synchronize,
            IgnoreIfExistsInDesitnation
        }
     /// <summary>
        /// Clones and / or synchronizes the given IXPSimpleObject.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="targetSession"></param>
        /// <param name="synchronize">If set to true, reference properties are only cloned in case
        /// the reference object does not exist in the targetsession. Otherwise the exising object will be
        /// reused and synchronized with the source. Set this property to false when knowing at forehand
        /// that the targetSession will not contain any of the objects of the source.</param>
        /// <returns></returns>
        public object Clone(IXPSimpleObject source, UnitOfWork parentSession, XPClassInfo cloneClassInfo, CloneMethod sync)
        {
            if (source == null)
                return null;

            object sourceKey = source.Session.GetKeyValue(source);

            if (clonedObjects.ContainsKey(source))
                return parentSession.GetObjectByKey(cloneClassInfo,cloneClassInfo.KeyProperty.GetValue(clonedObjects[source]));

            
            NestedUnitOfWork nestedSession = parentSession.BeginNestedUnitOfWork();
            IXPSimpleObject clone = null;

            if (sync != CloneMethod.TransferOnly)
            {
                clone = (IXPSimpleObject)nestedSession.GetObjectByKey(cloneClassInfo, sourceKey);
                if (clone != null)
                {
                    if (sync == CloneMethod.IgnoreIfExistsInDesitnation)
                    {
                        clonedObjects.Add(source, clone);
                        return nestedSession.GetParentObject(clone);
                    }
                }
            }

            if (clone == null)
                clone = (IXPSimpleObject)cloneClassInfo.CreateNewObject(nestedSession);
      
            clonedObjects.Add(source, clone);

            try
            {
                XPClassInfo sourceClassInfo = source.Session.GetClassInfo(source.GetType());
                if (sourceClassInfo.KeyProperty.GetType() == cloneClassInfo.KeyProperty.GetType())
                    cloneClassInfo.KeyProperty.SetValue(clone, sourceKey);

                foreach (XPMemberInfo cloneMember in cloneClassInfo.PersistentProperties)
                {
                    XPMemberInfo sourceMem = sourceClassInfo.GetMember(cloneMember.Name);

                    if (sourceMem == null
                        || cloneMember is DevExpress.Xpo.Metadata.Helpers.ServiceField
                        || cloneMember.IsKey)
                        continue;

                    object val = null;
   
                    if (cloneMember.ReferenceType != null)
                    {
                        object createdByClone = cloneMember.GetValue(clone);
                        if (createdByClone != null)
                        {
                           
                            val = Clone((IXPSimpleObject)sourceMem.GetValue(source),
                                nestedSession,
                                nestedSession.GetClassInfo(cloneMember.MemberType),
                                sync==CloneMethod.TransferOnly?CloneMethod.Synchronize:sync);
                        }
                        else
                            if ((cloneMember.IsAggregated)
                                //REMOVE Below LINE IF YOU WANT TO MAINTAIN ONLY ONE WAY AGGREGATIOn
                                || (cloneMember.IsAssociation
                                    && cloneMember.GetAssociatedMember().IsAggregated)
                                )
                            {
                                val = Clone((IXPSimpleObject)sourceMem.GetValue(source), nestedSession,
                                       nestedSession.GetClassInfo(cloneMember.MemberType), sync);
                            }

                    }
                    else
                    {
                            val = sourceMem.GetValue(source);
                    }

                    if ((val != null) && !(val is DateTime && (DateTime)val == DateTime.MinValue))
                        cloneMember.SetValue(clone, val);
                }

                foreach (XPMemberInfo m in cloneClassInfo.CollectionProperties)
                {
                    if (m.HasAttribute(typeof(AggregatedAttribute)))
                    {
                        XPBaseCollection col = (XPBaseCollection)m.GetValue(clone);
                        XPBaseCollection colSource = (XPBaseCollection)sourceClassInfo.GetMember(m.Name).GetValue(source);

                        foreach (IXPSimpleObject obj in new ArrayList(colSource))
                        {
                            XPClassInfo targetinfo = col.GetObjectClassInfo();
                            col.BaseAdd(
                                Clone(obj, nestedSession,
                                    targetinfo, sync));
                        }
                    }
                }

                nestedSession.CommitTransaction(); //
                clonedObjects[source]= clone;
                return nestedSession.GetParentObject(clone);
            }
            catch
            {
                if (nestedSession.InTransaction)
                    nestedSession.RollbackTransaction();
            }

            return null;
        }

    
    
    }

Added By: Chris D at: 8/4/2015 9:56:17 AM    

Dear,

I face a real problem with your clonehelper. After implementing we recoginized that this helper will not only clone my recordset, it will also clone/create my relations.

So, for example i have a order management where i want to clone one order. But what happened is that the order will be cloned, but the underlying addresses (relation via keys) will be cloned, too. So, after cloning 10 orders, i have 10 times the same address in my address-masterdata ?

Any idea ?

Added By: Chris D at: 8/4/2015 10:50:22 AM    

To avoid creating the underlying record, i changed

If m.ReferenceType IsNot Nothing And NONEW=1 Then....

where NONEW=0.

Could you please have a short look if this is the right solution ?

Added By: Alexey (DevExpress Support) at: 8/4/2015 11:14:43 PM    Hello Chris,
Yes, it is possible to disable this part of code to disable creating of additional records.

How to allow users to create filter via the criteria editor before previewing a report

$
0
0

This example demonstrates how to display a popup window with the filter editor before showing report preview, and filtering the report using the filter specified in this window. For this purpose, a custom report parameters class - CriteriaReportParametersObject - is created. This class has the Criteria property decorated with the CriteriaOptionsAttribute. XAF automatically uses CriteriaPropertyEditor for properties decorated with this attribute. So, the CriteriaPropertyEditor will be displayed in the CriteriaReportParametersObject DetailView. To convert the string created by this editor to the CriteriaOperator appropriate for the report, use the CriteriaEditorHelper.GetCriteriaOperator method in the CriteriaReportParametersObject.GetCriteria. The following topics contain more information about these techniques:

How to: Use Criteria Property Editors
Filter Report Data Source via the ParametersObjectType Property

Question Comments

Added By: Gustavo Marzioni at: 10/5/2012 8:36:49 AM    

No version for 12.1?

Added By: Paolo Parente at: 1/23/2013 10:15:26 AM    

Is there the 12.2 version?

Added By: Anatol (DevExpress Support) at: 4/3/2013 3:49:26 AM    

I have published versions for 12.1 and 12.2. Since the ASP.NET version does not require any specific code, I have removed Web projects from the example to simplify the maintenance.

Added By: Quynh Thai Doan at: 7/23/2013 1:13:53 AM    

How to popup Criteria Editor Window in winApplication ListView?

Added By: Anatol (DevExpress Support) at: 7/29/2013 7:45:44 AM    

It appears that your question is not directly related to this example. Please create a new ticket for it and describe your task in greater detail.

Added By: Mobilise IT at: 8/4/2015 8:49:19 PM    

Hi,
I was looking for this function with ReportV2, is there any sample I can use?

Added By: Alexey (DevExpress Support) at: 8/4/2015 11:17:50 PM    Hello,
You can find a small sample project in the Using FilterString Editor to create Criteria for ReportsV2 thread.

How to import Google Calendar using Google Calendar API

$
0
0

This example demonstrates how you can use the Google Calendar API in your scheduling application. Google provides the corresponding guidelines regarding use of this API:
Google Calendar API 

Before using this API, make certain you have read and understand Google’s licensing terms. Next, you’ll need to generate a corresponding JSON file with credentials to enable the Google Calendar API.

We have a corresponding KB article which contains step-by-step description on how to generate this JSON file:
How to enable the Google Calendar API to use it in your application

After you generate this JSON file and put it in the Secret folder of this sample project, you can import appointments from a Google calendar into the SchedulerControl;
1. Click the "Connect" button to generate a list of available calendars for your Google account
2. Select a corresponding calendar from which to import appointments.
For importing appointments, we created a corresponding CalendarImporter class which creates Appointment instances based on loaded Event (Google.Apis.Calendar.v3.Data) instances.

Appointment entries obtained via the Google API are objects of the Google.Apis.Calendar.v3.Data.Event type. Each appointment entry is processed to create an XtraScheduler appointment, recurrence pattern or exception. To parse recurrence information contained within the appointment entry, a RecurrencePatternParser class is implemented. It creates the DevExpress.XtraScheduler.iCalendar.iCalendarEntryParser instance to parse recurrence information represented by a string in iCalendar format. The DevExpress.XtraScheduler.iCalendar.iCalendarEntryParser instance holds the parse results and provides access to property values by property names.
Note that a special method is required to link exceptions (changed or deleted occurrences) with their patterns, since they are created independently while processing Google appointment entries.

P.S. To run this example's solution, include the corresponding "Google Calendar API" assemblies into the project.
For this, open the "Package Manager Console" (Tools - NuGet Package Manager) and execute the following command:

Install-Package Google.Apis.Calendar.v3

 

Question Comments

Added By: Marco Calabri at: 7/10/2013 1:28:41 AM    

good morning to all,
thanks for the example
how can I import the "Description" field from Google Calendar?
thanks for your help

Added By: subbu .B at: 10/10/2013 10:48:16 PM    

Hi,
I need help.How can i implement same code in my windows phone app using c#.
Thnaks,

Added By: Stephen Wright at: 7/4/2015 1:01:28 PM    

Thanks for the example. I have downloaded the latest DLL's from the website. The code fails on line 111

UserProfile.Instance.Calendars = (CalendarFeed)service.Query(query);

the catch then says it is an invalid username/password. But I know these to be correct because I use them to login via chrome.
Can someone suggest what I've left out.

Regards.

Added By: Oleg (DevExpress Support) at: 7/6/2015 3:36:33 AM    

Hello Stephen,
We were able to reproduce the issue. It seems that something was changed in Google API. We need additional time to investigate the issue on our side and find a corresponding solution.
We will update the status of this ticket once we have any results.

Added By: Stephen Wright at: 7/6/2015 4:03:57 AM    

Thank you. Trawling through the system, it appears that oAuth is the way to get in, but working that out is like wading through treacle.
I know I have the export .ics on the schedulergrid but I have to delete all the calendar entries and then re-import as the web interface doesn't check for duplicates.

Web Report Designer - How to open a report with an untyped DataSet 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 serialize a report to XML with an untyped DataSet as a data source

ASPxHtmlEditor - How to manipulate ASPxHtmlEditor View Areas by CustomToolbarButton

$
0
0

This example demonstrates how to manipulate ASPxHtmlEditor View Areas by CustomToolbarButton.

1) Wrap ASPxHtmlEditor with ASPxCallbackPanel to programmatically send a callback to the server;
2) Define CustomToolbarButton for ASPxHtmlEditor;
3) Handle the client-side ASPxClientHtmlEditor.CustomCommand event and perform a callback via the ASPxClientCallbackPanel.PerformCallback method;
4) Handle the ASPxCallbackPanel.Callback event and define View Areas enabled via the ASPxHtmlEditor.Settings property.

ASPxGridLookup - How to bind a lookup based on multiple selection of another lookup

$
0
0

This example demonstrates how to implement two cascaded ASPxGridLookup controls:
To implement it, perform the following steps:

1) Handle the server-side ASPxGridLookup.Init event of a "detail" lookup and subscribe to the CustomCallback event of a nested ASPxGridView object;
2) Handle the client-side ASPxClientGridLookup.ValueChanged event of a "master" lookup;
3) Perform a custom callback of the "detail" ASPxGridLookup via the ASPxClientGridLookup.GetGridView().PerformCallBack method;
4) Handle the "detail" ASPxGridView.CustomCallback event and define a filter expression for a "detail" datasource based on selected values of the "master" lookup;
5) Save a modified select command to the session to load it when the "detail" ASPxGridLookup/ASPxGridView is initialized after a callback.

Question Comments

Added By: Rick Astley at: 3/12/2015 3:49:38 AM    

This does not work inside editform template.
I was evaluating your componente and came to conclusiion zhat you really really need to take a good look at your stuf and start fixing it.

Added By: Larry (DevExpress Support) at: 3/13/2015 3:33:58 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T219124: The E3959 example does not work in grid's EditForm. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: John Daren Dizon 1 at: 8/5/2015 3:11:59 AM    

Hello, can I ask how can I combine multiple criteria for my filterexpression?

Added By: Larry (DevExpress Support) at: 8/5/2015 6:50:29 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T275116: ASPxGridLookup - How to bind a lookup based on multiple selection of another lookup if multiple filter criteria is used. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to update a document displayed by the ASPxDocumentViewer within the ASPxPopupControl

$
0
0

This example illustrates how to update a web report's content on the fly by placing the ASPxDocumentViewer within the ASPxPopupControl and calling the ASPxClientDocumentViewer.Refresh method.

An additional hidden field is provided on the web page to pass parameter values to a report before its document is set forth and published using the ASPxDocumentViewer.

Question Comments

Added By: Nasser Alazemi at: 7/2/2015 10:09:32 PM    

This example not working

Added By: Dmitry Tok (DevExpress Support) at: 7/3/2015 2:42:21 AM    

Hello Nasser,

I have just tried to run this example online (here is a direct link) and download a sample project to my machine. In both cases, the sample project from this Code Example operates correctly. It would be great if you register a new ticket in our Support Center and describe what error you are facing with the sample project from this Code Example.

Thanks,
Dmitry

Added By: Alexandros Pappas 1 at: 8/5/2015 6:55:48 AM    

It is better to assign the report in the ASPxDocumentViewer's OnLoad event. And it is only necessary to do it upon a callback or a postback. Callbacks occur when the ASPxDocumentViewer is shown, and postbacks occur when a button on the ASPxDocumentViewer's toolbar is clicked. This has the advantage, that when the page contains other controls that produce callbacks like grids, the report is not created, saving processing time. I also found out, that there is no need to call this.DocumentViewer1.DataBind(), it does not seem to make any difference. Therefore, Default.aspx.cs can be written as follows:

using System;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
   protected void DocumentViewer1_Load(object sender, EventArgs e)
   {
       if (IsCallback || IsPostBack)
       {
           var hf = (HtmlInputHidden)this.Page.FindControl("ReportMsg");
           var report = new XtraReport1();
           report.Parameters["test"].Value = hf.Value.ToString();
           report.CreateDocument();
           this.DocumentViewer1.Report = report;
       }
   }
}

The OnLoad event must be added to DocumentViewer1:
                   <dxxr:ASPxDocumentViewer ID="DocumentViewer1" runat="server" ClientInstanceName="DocumentViewer"
                       ShowLoadingPanelImage="False" LoadingPanelText="" OnLoad="DocumentViewer1_Load">
                       <SettingsSplitter SidePaneVisible="False" />
                   </dxxr:ASPxDocumentViewer>

How to create and setup an XtraReport report for exporting to a Stream in a non-XAF application

$
0
0

Scenario
If you want to use XAF report in non-XAF application, then you can follow these instructions to achieve this. 
Since XAF stores reports in the database, and XAF reports use the ObjectSpace to retrieve data from database, it is necessary to connect to the XAF database and create ObjectSpace to use XAF reports in a non-XAF application.

Steps to implement: 

1) Create a custom class which implements the IReportObjectSpaceProvider interface. Please refer to the ExportXafReport\MyReportObjectSpaceProvider.xx file for implementation details.
2) Create a custom class which inherits the ReportDataSourceHelper class and override the CreateReportObjectSpaceProvider method as shown in the ExportXafReport/MyReportDataSourceHelper.xx class.
3) Create ObjectSpace using the approach from the Access XAF Application Data in a non-XAF Application article and register required types in the TypesInfo. Please refer ExportXafReport/Program.xx file.
4) Use the approach described in the How to: Print a Report Without Displaying a Preview article to access and print a report.

This example contains XPO and EF implementations.


How to use the ASPxPageControl control in Full Screen mode (100% browser Width and Height)

$
0
0

This example demonstrates how to resize a DevExpress ASP.NET control (for example, ASPxPageControl) to occupy the entire browser window (a Full Screen mode)

1) Reset the following default CSS rules for a page:

[CSS]
body,html{padding:0;margin:0;}

2) Set the ASPxPageControl.Width property to "100%" and set an initial ASPxPageControl.Height property;

[ASPx]
<dx:ASPxPageControl...Height="100px"Width="100%">

3) Set the ASPxPageControl.Paddings.Padding to "0px" to disable default offsets/paddings (this step is optional);

[ASPx]
<dx:ASPxPageControl...><PaddingsPadding="0px"/></dx:ASPxPageControl>

4) Implement a function that should resize the control within the entire browser window;

5) Call this function when:

- the control is initialized for the first time (handle the client-side ASPxClientControl.Init event);

- the browser window size is changed/resized (subscribe to the "resize" event and handle it via the client-side ASPxClientUtils.AttachEventToElement method):

[ASPx]
<dx:ASPxPageControl...><ClientSideEventsInit="OnInit"/></dx:ASPxPageControl>

[JScript]
function OnInit(s, e){ AdjustSize(); ASPxClientUtils.AttachEventToElement(window, "resize", function(evt){ AdjustSize();});}function AdjustSize(){var height = document.documentElement.clientHeight; pc.SetHeight(height);}

See Also:
E1081: How to use the ASPxGridView control (with the enabled vertical scrollbar) in a Full Screen mode (100% browser Width and Height)
Splitter - Fullscreen Mode

Prism - How to define Prism regions for various DXDocking elements

$
0
0

Since Prism RegionManager supports standard controls only, it is necessary to write custom RegionAdapters (a descendant of the Microsoft.Practices.Prism.Regions.RegionAdapterBase class) in order to instruct Prism RegionManager how to deal with DXDocking elements.

This example covers the following scenarios:

Using a LayoutPanel as a Prism region. The LayoutPanelAdapter class creates a new ContentControl containing a View and then places it into a target LayoutPanel.

Using a LayoutGroup as a Prism region. The LayoutGroupAdapter creates a new LayoutPanel containing a View, and then adds it to a target LayoutGroup’s Items collection,

Using a DocumentGroup as a Prism region. The DocumentGroupAdapter behaves similarly to the LayoutGroupAdapter. The only difference is that it manipulates DocumentPanels.

Question Comments

Added By: K.Wessing at: 6/21/2012 1:19:15 AM    

starting in version 12.1 I get an exception, in version 11.2 the sample did work
(I based my application on this)

System.ArgumentException was unhandled by user code
  Message=This RegionManager does not contain a Region with the name 'LeftRegion'.
Parameter name: regionName
  Source=Microsoft.Practices.Prism
  ParamName=regionName
  StackTrace:
       at Microsoft.Practices.Prism.Regions.RegionManagerExtensions.AddToRegion(IRegionManager regionManager, String regionName, Object view)
       at PrismOnDXDocking.ExampleModule.ExampleModule.Initialize() in C:\Users\k.wessing\Documents\Samples\DXDocking for WPF\12.1.4\E3339\PrismOnDXDocking.ExampleModule\Module.cs:line 58
       at Microsoft.Practices.Prism.Modularity.ModuleInitializer.Initialize(ModuleInfo moduleInfo)
  InnerException:

Added By: Allan Nielsen 2 at: 7/3/2012 6:45:45 PM    

I downloaded this example and tried to run it via your example runner. We are using DXv2 (12.1) and it generates an exception as found by K.Wessing above. I also made sure I was using an up-to-date version of Prism Mef (v4.1):

System.ComponentModel.Composition.CompositionException was unhandled
  Message=The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.

1) This RegionManager does not contain a Region with the name 'LeftRegion'.
Parameter name: regionName

Resulting in: An exception occurred while initializing module 'ExampleModule'.
    - The exception message was: This RegionManager does not contain a Region with the name 'LeftRegion'.
Parameter name: regionName
    - The Assembly that the module was trying to be loaded from was:PrismOnDXDocking.ExampleModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
    Check the InnerException property of the exception for more information. If the exception occurred while creating an object in a DI container, you can exception.GetRootException() to help locate the root cause of the problem.
  

Resulting in: An exception occurred while calling the 'OnImportsSatisfied' method on type 'Microsoft.Practices.Prism.MefExtensions.Modularity.MefModuleManager'.

Resulting in: Cannot activate part 'Microsoft.Practices.Prism.MefExtensions.Modularity.MefModuleManager'.
Element: Microsoft.Practices.Prism.MefExtensions.Modularity.MefModuleManager --> Microsoft.Practices.Prism.MefExtensions.Modularity.MefModuleManager --> AssemblyCatalog (Assembly="Microsoft.Practices.Prism.MefExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")

Resulting in: Cannot get export 'Microsoft.Practices.Prism.MefExtensions.Modularity.MefModuleManager (ContractName="Microsoft.Practices.Prism.Modularity.IModuleManager")' from part 'Microsoft.Practices.Prism.MefExtensions.Modularity.MefModuleManager'.
Element: Microsoft.Practices.Prism.MefExtensions.Modularity.MefModuleManager (ContractName="Microsoft.Practices.Prism.Modularity.IModuleManager") --> Microsoft.Practices.Prism.MefExtensions.Modularity.MefModuleManager --> AssemblyCatalog (Assembly="Microsoft.Practices.Prism.MefExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")

  Source=System.ComponentModel.Composition
  StackTrace:
       at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition)
       at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(ComposablePart part, ExportDefinition export, Boolean isSharedPart)
       at System.ComponentModel.Composition.Hosting.CatalogExportProvider.CatalogExport.GetExportedValueCore()
       at System.ComponentModel.Composition.Primitives.Export.get_Value()
       at System.ComponentModel.Composition.ExportServices.GetExportedValueFromLazy[T](Export export)
       at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValueCore[T](String contractName, ImportCardinality cardinality)
       at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValue[T](String contractName)
       at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValue[T]()
       at Microsoft.Practices.Prism.MefExtensions.MefBootstrapper.InitializeModules()
       at Microsoft.Practices.Prism.MefExtensions.MefBootstrapper.Run(Boolean runWithDefaultConfiguration)
       at Microsoft.Practices.Prism.Bootstrapper.Run()
       at PrismOnDXDocking.App.OnStartup(StartupEventArgs e) in C:\Users\anielsen\Downloads\DXDocking for WPF\12.1.4\E3339\PrismOnDXDocking\Application.xaml.cs:line 34
       at System.Windows.Application.<.ctor>b__1(Object unused)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.TranslateAndDispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.Run()
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at System.Windows.Application.Run()
       at PrismOnDXDocking.App.Main() in C:\Users\anielsen\Downloads\DXDocking for WPF\12.1.4\E3339\PrismOnDXDocking\obj\x86\Debug\Application.g.cs:line 50
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Added By: jplopez42 at: 7/4/2012 1:18:46 AM    

Hello, we have an issue with your sample E3339 (related to the use of regions and adapters). The sample is successfully working with the 11.2.11 version in one of our testing computers. But we’re now integrating the last version of DevExpress (12.1.4) in our sandbox computer and it doesn’t work: the project is compiling but it doesn’t work (the adapters aren’t working: the flow execution isn’t entering in the adapters, in the function Adapt). We’re experiencing the same problem than K.Wessing: System.ArgumentException was unhandled by user code
  Message=This RegionManager does not contain a Region with the name 'LeftRegion'.
We have been checking your technical support and it seems there was another issue between the 11.1.x and the 11.2.x, and your teams adapted the sample project for the new DevExpress version. Is it possible that it’s happening the same?
Thanks,
       Juan Lopez

Added By: Bertrand Decoux at: 8/23/2012 8:55:43 PM    

I am using the LayoutGroupAdapter
I would like to be able to switch from one view to an other within the same LayoutGroup region.
I 've added the Remove action:
 if (e.Action == NotifyCollectionChangedAction.Remove)
            {
regionTarget.Items.Clear();
}
Scenario:
in region : <dxd:LayoutGroup cal:RegionManager.RegionName="{x:Static Infrastructure:RegionNames.DetailsRegion}" />
#1 Add a viewA - OK
#2 Remove viewA - OK
#3 Add viewB - OK
#4 Remove viewB - OK
#5 add viewA - Getting ERROR below
Please advice.
Thank you
-
{"Specified element is already the logical child of another element. Disconnect it first."}
-
   at System.Windows.FrameworkElement.ChangeLogicalParent(DependencyObject newParent)
   at System.Windows.FrameworkElement.AddLogicalChild(Object child)
   at DevExpress.Xpf.Docking.LayoutPanel.OnControlPropertyChanged(UIElement control, UIElement oldControl)
   at DevExpress.Xpf.Docking.LayoutPanel.OnControlChanged(UIElement control, UIElement oldControl)
   at DevExpress.Xpf.Docking.LayoutPanel.<.cctor>b__1(DependencyObject dObj, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
...

Added By: NP23 at: 7/29/2013 12:03:02 PM    

The Remove event is not handled in the documentgroup adapter which does not reclaim the memory when tab is closed.

Added By: Simon Cui 1 at: 8/12/2013 9:13:37 AM    

Hide the leftregion, the navbar be removed, and hide leftregin again, throw error.

Added By: Sergey Wereteychenko at: 9/3/2013 12:27:27 AM    

Why this example is so bugged?
After detaching a panel - disappears a content, please try detach Toolbox...
And why this example craches every time, when attach-detach event happening...

Please, supply Working example.

Added By: Sergey Wereteychenko at: 9/3/2013 12:36:20 AM    

private void OnItemsCollectionChanged(IRegion region, LayoutGroup regionTarget, object sender, NotifyCollectionChangedEventArgs e)
        {
            if (lockItemsChanged)
            {
                return;
            }
            if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                lockViewsChanged = true;
                var lp = (LayoutPanel)e.OldItems[0];
                var view = lp.Content;
                //lp.Content = null;
                region.Remove(view);
                lockViewsChanged = false;
            }
        }

Cause of removing content is "lp.Content = null;" row...
Why was existing this row in example?

Added By: NP23 at: 11/5/2013 11:02:15 AM    

Can you complete the code for remove action. We have something as below to remove any tabs that are floating or in the default layout group. it does not find tabs in newly created layout groups.

  case NotifyCollectionChangedAction.Remove:
                    List<DocumentPanel> panelToRemove = new List<DocumentPanel>();
                    List<FloatGroup> floatGroupToRemove = new List<FloatGroup>();
                    DockLayoutManager managerRemove = regionTarget.GetDockLayoutManager();
                    foreach (DocumentPanel panel in regionTarget.Items)
                    {
                        foreach (IPanelInfo oldItem in e.OldItems)
                        {
                            if (panel.Caption.Equals(oldItem.Title))
                            {
                                panelToRemove.Add(panel);
                            }
                        }
                    }

                    foreach (DocumentPanel pnl in panelToRemove)
                    {
                        regionTarget.Items.Remove(pnl);
                    }

                    panelToRemove.Clear();

                    foreach (var floatGroup in managerRemove.FloatGroups)
                    {
                        foreach (DocumentPanel panel in floatGroup.Items)
                        {
                            foreach (IPanelInfo oldItem in e.OldItems)
                            {
                                if (panel.Caption.Equals(oldItem.Title))
                                {
                                    panelToRemove.Add(panel);
                                }
                            }
                        }

                        foreach (DocumentPanel pnl in panelToRemove)
                        {
                            floatGroup.Items.Remove(pnl);
                        }

                        if (floatGroup.Items.Count == 0 )
                        {
                            floatGroupToRemove.Add(floatGroup);
                        }
                    }

                    foreach (FloatGroup floatGroup in floatGroupToRemove)
                    {
                        managerRemove.FloatGroups.Remove(floatGroup);
                    }

                    break;

Added By: Artem Dubenko 2 at: 8/6/2015 12:54:59 PM    

Unfortunately this example doesn't support selection/activation of the views. A call to IRegion.Activate(view) will have no effect.

How to customize the filter criteria before it is applied to GridView

$
0
0

If you need to modify the GridView filter right before it is sent to the DataController, you can use the ColumnView.SubstituteFilter event.

This example demonstrates this approach.

How to sort groups by number of records in the group

How to handle events of editor's controls in Detail View

$
0
0

This example demonstrates how to handle specific events of Property Editors and ObjectSpace, indicating changes with object in the Detail View.

See Also:
Access Editor Settings

Question Comments

Added By: Mysoft Systems at: 11/14/2012 10:51:11 AM    

Do you have a similar document for what listview controllers? This document was very helpful - it would be nice to have a similar document for listview.

Thanks

Added By: Raumnz at: 8/7/2015 3:27:44 PM    

Hi: I like it....could  you add  a simmilar code sample for WEB controlller. Thanks

Viewing all 7205 articles
Browse latest View live


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