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

How to add a custom button to a column header in a grid

$
0
0

This example illustrates how to add a custom button to a column header in a grid and assign custom actions to it.

Question Comments

Added By: Thomas Mayfield at: 1/3/2015 2:58:10 PM    

In both 13.1 and 14.1, this sample shows an empty button, and setting the image or caption doesn't appear to fix that. How do you get it to display an image or caption in the custom button?

Added By: Sasha (DevExpress Support) at: 1/5/2015 2:26:06 AM    

Hello Thomas,
I've created a separate How to show a caption and an image within a custom painted button ticket for discussing this question. You will find an answer there.


How to implement cascaded combo box columns in ASPxGridView without using templates

$
0
0

The example illustrates how to create an editable grid with cascaded combobox columns. The implementation of the example includes the handling of manual callbacks and providing items for appropriate arguments.
By default, the combobox column uses a datasource that displays all records to show a user Text values instead of record keys.

Question Comments

Added By: Deborah Carter at: 5/9/2014 3:45:18 AM    

I looked at the code below and it looks like what I have.  The page just never gets to it.  Here is the complete asp page:

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="mnt_Person.aspx.vb" Inherits="mnt_Person" %>

<%@ Register assembly="DevExpress.Web.v13.2, Version=13.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v13.2, Version=13.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
  <script type="text/javascript">
   // <![CDATA[
      var lastServiceDivNo = null;
      function OnServiceDivNoChanged(cmbServiceDivisionNm) {
          if (grid.GetEditor("ServiceAreaNm").InCallback())
              lastServiceDivNo = cmbServiceDivisionNm.GetValue().toString();
          else
              grid.GetEditor("ServiceAreaNm").PerformCallback(cmbServiceDivisionNm.GetValue().toString());
      }
      function OnEndCallback(s, e) {
          if (lastServiceDivNo) {
              grid.GetEditor("ServiceAreaNm").PerformCallback(lastServiceDivNo);
              lastServiceDivNo = null;
          }
      }
   // ]]>
   </script>
   <asp:Label ID="Label2" runat="server" CssClass="pageheader" Width="100%" Text="Supervisor Maintenance"></asp:Label>
   <br />
   <dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" AutoGenerateColumns="False"
       DataSourceID="SqlDataSource1" KeyFieldName="Person_Key">
       <Columns>
          <dx:GridViewCommandColumn ShowClearFilterButton="True" ShowNewButton="True"
               VisibleIndex="1">
           </dx:GridViewCommandColumn>
           <dx:GridViewDataTextColumn FieldName="Person_Key" VisibleIndex="2">
               <EditFormSettings Visible="False" />
           </dx:GridViewDataTextColumn>
           <dx:GridViewDataTextColumn FieldName="Supervisor_No" VisibleIndex="3">
           </dx:GridViewDataTextColumn>
           <dx:GridViewDataComboBoxColumn FieldName="ServiceDivisionNm" VisibleIndex="4">
               <PropertiesComboBox DataSourceID="SqlDataSource2" TextField="ServiceDivisionNm" EnableSynchronization="False"
                   ValueField="ServiceDivisionNo">
                    <ClientSideEvents SelectedIndexChanged="function(s, e) {OnServiceDivNoChanged(s); }"></ClientSideEvents>
                </PropertiesComboBox>
           </dx:GridViewDataComboBoxColumn>
           <dx:GridViewDataComboBoxColumn FieldName="ServiceAreaNm" VisibleIndex="5">
               <PropertiesComboBox EnableSynchronization="False">
               <ClientSideEvents EndCallback="OnEndCallback"></ClientSideEvents>
               </PropertiesComboBox>
           </dx:GridViewDataComboBoxColumn>
                       <dx:GridViewDataTextColumn FieldName="TransNoPrefix" VisibleIndex="8">
           </dx:GridViewDataTextColumn>
           <dx:GridViewDataTextColumn FieldName="Supervisor" VisibleIndex="9">
           </dx:GridViewDataTextColumn>
           <dx:GridViewDataCheckColumn FieldName="IsActive" VisibleIndex="10">
           </dx:GridViewDataCheckColumn>
       </Columns>
       <SettingsEditing Mode="Batch">
       </SettingsEditing>
       <Settings ShowFilterRow="True" />
       <SettingsCommandButton>
           <ClearFilterButton Text="Clear">
           </ClearFilterButton>
       </SettingsCommandButton>
       <SettingsDataSecurity AllowDelete="False" />
   </dx:ASPxGridView>
   

   <asp:SqlDataSource ID="SqlDataSource2" runat="server"
       ConnectionString="<%$ ConnectionStrings:CCFieldServiceConnectionString %>"
       SelectCommand="SELECT distinct [ServiceDivisionNo], [ServiceDivisionNm] FROM [dim_Organization]">
   </asp:SqlDataSource>
   
   <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:CCFieldServiceConnectionString %>"
       SelectCommand="SELECT distinct [ServiceAreaNo], [ServiceAreaNm] FROM [dim_Organization] WHERE ServiceDivisionNo = ? ">
       <SelectParameters>
           <asp:Parameter Name="?" />
       </SelectParameters>
   </asp:SqlDataSource>

   <asp:SqlDataSource ID="SqlDataSource1" runat="server"
       ConnectionString="<%$ ConnectionStrings:CCFieldServiceConnectionString %>"
       
       SelectCommand="SELECT dbo.dim_Person.Person_Key, dbo.dim_Person.Supervisor_No, dbo.dim_Person.TransNoPrefix, dbo.dim_Person.Supervisor, dbo.dim_Person.IsActive, dbo.dim_Organization.ServiceAreaNm, dbo.dim_Organization.ServiceDivisionNm FROM dbo.dim_Person INNER JOIN dbo.dim_Organization ON dbo.dim_Person.ServiceDivisionNo = dbo.dim_Organization.ServiceDivisionNo AND dbo.dim_Person.ServiceAreaNo = dbo.dim_Organization.ServiceAreaNo WHERE (dbo.dim_Person.IsActive = 1)">
     
   </asp:SqlDataSource>
   

</asp:Content>

Added By: Larry (DevExpress Support) at: 5/9/2014 5:31:02 AM    Hello Deborah,

I have created a separate ticket on your behalf to process your inquiry more effectively:

How to implement cascaded combo box columns in ASPxGridView without using templates

Please refer to it for further correspondence.

 

Added By: S Abowitz at: 8/25/2014 10:26:50 AM    

I don't understand how this code work for new rows if in the grid_celleditorinitialize sub, if checks If (Not grid.IsNewRowEditing) Then before getting the filter value, so how does the second combo prefill for new rows after country is selected?

Please explain,

Added By: Mike (DevExpress Support) at: 8/25/2014 11:54:17 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T143924: E3689 - ASPxGridView - How to filter child combobox when IsNewRowEditing = False. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Sathish Rao at: 9/7/2014 11:13:12 PM    

Can you please share the sample code of this for an MVC application.
Thank you

Added By: Larry (DevExpress Support) at: 9/7/2014 11:23:10 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T148238: How to implement cascaded combo box columns in GridView without using templates. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: antoni levano at: 10/18/2017 12:36:13 PM    thanks. it works!!

ASPxGridView - How to adjust Edit Form layout using the EditFormLayoutProperties property

$
0
0
In this example, the Edit Form layout is customized by using the EditFormLayoutProperties property. The CategoryID column's editor is set to ASPxComboBox. The ProductID column's editor is displayed only when editing an existing row. All editor locations are customized with the ColSpan and RowSpan properties. The ProductID field is marked with an asterisk like the required field.

See Also:
ASPxGridView - How to hide the EditForm editor and column caption programmatically
Question Comments

Added By: Felipe Cruz at: 10/19/2017 2:51:21 AM    Hi, This is a nice example.

Can you help me with doing something like this:

grid.EditFormLayoutProperties.FindItemOrGroupByName(name);

at client side? I have a ASPxUploadControl in edit form and I want to trigger the .upload in JS

How to localize WinForms Scheduler UI using the Localizer class descendant

How to create complex custom controls (XRTreeList and XRGrid)

$
0
0

This example demonstrates how to create custom data-aware controls that have a complex structure. The example consists of two projects:
- DevExpress.XtraReports.CustomControls. Contains all classes and methods related to custom controls.
- CustomControlExample. This project is for testing the aforementioned custom controls. This project invokes End-User Report Designers and Print Previews for both controls.

Take special note of the following classes and methods when examining the CustomControls project:
1. XRTreeList and XRGrid. They are XRControl descendants and contain all required properties and methods related to their visual representation.
1.1. The XRControl.CreatePresenter method allows you to create different presenters for visualizing your control at runtime and design time.
1.2. The XRControl.WriteContentTo method generates the visual representation and passes it to the resulting document.
1.3. The XRControl.CollectAssociatedComponents method allows you to link external objects (data source information and other Component properties) to your control.
1.4. The XRControl.CopyDataProperties method is required to inform your control of how to clone data source related properties.
1.5. The XRControl.CreateCollectionItem method defines how to create new collection items in your control.
1.6. The XRControl.CreateStyles method is responsible for creating specific control styles.
1.7. The XRControl.CreateScripts method creates scripts specific for this control.

2. XRTreeListDesigner and XRGridDesigner. These classes describe the design-time behavior of corresponding controls.
2.1. The XRControlDesigner.GetFilteredProperties method determines what properties should be visible in the Property Grid.
2.2. The XRControlDesigner.RegisterActionLists method fills the XRControl smart tag with required actions.

3. XRTreeListRuntimePresenter and XRGridRuntimePresenter. These classes generate visual representation of your controls.
3.1. The XRControlPresenter.CreateBrick method creates a container brick for displaying the control content.
3.2. The XRControlPresenter.PutStateToBrick method generates inner content based on the current control state.


Important note: the VB.NET solution is for VS 2012 or newer, because it uses new operators that do not exist in VS 2010.

See also:
How to: Create a Numeric Label
How to: Create a Progress Bar Control
Question Comments

Added By: Mohsen Abo-Ghaly at: 11/29/2016 10:15:12 AM    Hello,

Thanks for the good/smart approach.

Can we use this code/approach with the version 2012 - 2.6?

Thanks
Mohsen
Added By: Vasily (DevExpress Support) at: 11/30/2016 4:30:41 AM    

Hi Mohsen,

This example is provided for versions 15.2+. Tough there is no ready-to use version of this example for earlier versions, you can use the following solutions for version 12.2:
- If you would like to draw a table in your report, use the approach described in the Table Report  help topic. 
- If you would like to draw a tree list in your report, use the WinControlContainer component to insert the WinForms TreeList control there.
If you have any further questions regarding these approaches, feel free to create a separate ticket on your behalf.

Alternatively, you can downgrade this example's code to your version, but this will require access to DevExpress source code. That's because an internal non-documented functionality is used in this code example.

Added By: Mohsen Abo-Ghaly at: 11/30/2016 10:30:51 AM    Hello Vasily,

Thank you for your attention.

Will study it and try.

I think that we will upgrade soon.

Need to ask: As I can remmeber, in the newest versions the ability to send the main controls like "ASPxGridView" to the ReportViewer/ReportDesigner is added by default to the control features - correct?

if yes, there is no need to use this sample because it will be part (by default) in the new versions.

Thanks
Mohsen
Added By: Dmitry Tok (DevExpress Support) at: 11/30/2016 10:47:06 AM    Hello Mohsen,

Would you please clarify what you mean by "send the main controls"? We provide a Code Example that demonstrates how to convert an instance of the ASPxGridView to a report: How to convert and then print an ASPxGridView by using the XtraReport.

In addition, we offer a special ASPxGridViewExporter component to export/print ASPxGridView data to several output formats. Take a look at the online Exporting Data - Exporting to PDF, XLS, XLSX and RTF demo to see this feature in action.

See Also:
Export Overview help topic.


Thanks,
Dmitry

Added By: Mohsen Abo-Ghaly at: 11/30/2016 11:02:34 AM    Hello Dmitry,

Yes - I mean "convert an instance of the main coontols (like ASPxGridView) to a report" - I got it 

I know that there is a difference between this and the current ticket code but it will work if we need to convert  one grid to report.

Anyway, the current sample is working with windows forms controls "like XRGrid" - what about the ASP.NET controls?

Thanks
Mohsen Added By: Dmitry Tok (DevExpress Support) at: 11/30/2016 11:13:29 AM    

Hello Mohsen,

The XRGrid control you are referring to isn't a Windows Forms control, but an implemented report control that replicates the functionality of a well-known Grid Control. The following approach was used to implement this control: Creating Custom Controls.

Thanks

Added By: Mohsen Abo-Ghaly at: 11/30/2016 11:20:24 AM    Hello Dmitry,

Thanks for your interest.

Will give it a try.

Thanks a lot for your time. Added By: L Alex at: 10/19/2017 10:43:15 PM    Hello,

the Html View of XRTreelist can not execute in the designer!

GridView - Text automatically scrolls horizontally when it doesn't fit into cell bounds

$
0
0

This example demonstrates a creeping line in a grid view cell when its text doesn't fit into its bounds. This feature works together with the cell's tool tip when a user points to a cell with the mouse cursor. It's sufficient to process GridView's CustomDrawCell event to implement this behavior.

Dashboard Designer - How to import shape files into Map Dashboard Items using a custom OpenFileDialog

$
0
0

This example demonstrates how to load custom shape files into Map Dashboard Items with custom code. This can be useful if you decide to set a specific InitialDirectory or load shape files from a database.

How to generate and assign a sequential number for an XPO business object within a database transaction as part of a successful saving process (XAF)

$
0
0

Scenario
This is a variation of the How to generate and assign a sequential number for a business object within a database transaction, while being a part of a successful saving process XPO example, which was specially adapted for XAF applications.

In particular, for better reusability and more smooth integration with the standard XAF CRUD Controllers, all the required operations to generate sequences are managed within the base persistent class automatically when a persistent object is being saved. For more developer convenience, this solution is organized as a reusable XAF module - GenerateUserFriendlyId.Module. This module consists of several key parts:

    - Sequence and SequenceGenerator are auxiliary classes that take the main part in generating user-friendly identifiers. Take special note that the SequenceGenerator.Initialize method must be called during your XAF application startup for the correct operation.

    - UserFriendlyIdPersistentObject is a base persistent class that subscribes to XPO's Session events and delegates calls to the core classes above. Normally, you must inherit your own business classes from this base class to get the described functionality in your project.

    - IUserFriendlyIdDomainComponent is a base domain component that should be implemented by all domain components that require the described functionality.

Check the original example description first for more information on the demonstrated scenarios and functionality.




Steps to implement
1. Copy and include the GenerateUserFriendlyId.Module project into your solution and make sure it is built successfully.  Invoke the Module or Application Designer for the YourSolutionName.Module/Module.xx  or YourSolutionName.Wxx/WxxApplication.xx files by double-clicking it in Solution Explorer. Invoke the Toolbox (Alt+X+T) and then drag & drop the GenerateUserFriendlyIdModule component into the modules list on the left.

2. For apps with no security or with the Client-Side Security (XPObjectSpaceProvider or SecuredObjectSpaceProvider):
In the YourSolutionName.Wxx/WxxApplication.xx files, modify the CreateDefaultObjectSpaceProvider method to call the SequenceGenerator.Initialize method as shown in the Demo.Wxx\WxxApplication.xx files:

[C#]
...protectedoverridevoidCreateDefaultObjectSpaceProvider(CreateCustomObjectSpaceProviderEventArgsargs){GenerateUserFriendlyId.Module.Utils.SequenceGenerator.Initialize(this,args.ConnectionString);//!!!...}

For apps with the Middle Tier Security (DataServerObjectSpaceProvider):
In the YourSolutionName.ApplicationServer project, locate and modify the serverApplication_CreateCustomObjectSpaceProvider or CreateDefaultObjectSpaceProvider  methods to call the SequenceGenerator.Initialize method as shown below:

[C#]
privatestaticvoidserverApplication_CreateCustomObjectSpaceProvider(objectsender,CreateCustomObjectSpaceProviderEventArgse){GenerateUserFriendlyId.Module.SequenceGenerator.Initialize((XafApplication)sender,e.ConnectionString);

In the same code file, locate the serverApplication.Dispose(); line and move to the end of the Main or OnStop methods in the Console or Windows Service applications respectively (in the latter case, the "serverApplication" variable must also be declared in the higher scope).


3.
 If you are using pure XPO classes, then inherit your required business classes from the module's UserFriendlyIdPersistentObject one and use the derived SequenceNumber property as required:

[C#]
publicclassContact:GenerateUserFriendlyId.Module.BusinessObjects.UserFriendlyIdPersistentObject{[PersistentAlias("concat('C', ToStr(SequentialNumber))")]publicstringContactId{get{returnConvert.ToString(EvaluateAlias("ContactId"));}}

If you are using DC interfaces, then implement the IUserFriendlyIdDomainComponent interface by your custom domain component:

[C#]
publicinterfaceIDocument:GenerateUserFriendlyId.Module.BusinessObjects.IUserFriendlyIdDomainComponent{[Calculated("concat('D', ToStr(SequentialNumber))")]stringDocumentId{get;}

Additionally for DC, use the UserFriendlyIdPersistentObject as a base class during your custom domain component registration, e.g.:

[C#]
XafTypesInfo.Instance.RegisterEntity("Document",typeof(IDocument),typeof(GenerateUserFriendlyId.Module.BusinessObjects.UserFriendlyIdPersistentObject));

Note that the sequential number functionality shown in this example does not work with DC shared parts , because it requires a custom base class, which is not allowed for shared parts.

4. For more information, download and review the Address, Contact, and IDocument types within the Demo.Module project. These are test business objects that demonstrate the use of the described functionality for XPO and DC respectively. A required format for the user-friendly identifier property in these end classes is defined within an aliased property (ContactId in the example above) by concatenation of a required constant or dynamic value with the SequentialNumber property provided by the base UserFriendlyIdPersistentObject class. So, if you need to have a different format, modify the PersistentAliasAttribute expression as your business needs dictate.

 

IMPORTANT NOTES

1. As an alternative, you can use a more simple solution that is using the DistributedIdGeneratorHelper.Generate method as shown in the FeatureCenter demo ("%Public%\Documents\DXperience 13.X Demos\eXpressApp Framework\FeatureCenter\CS\FeatureCenter.Module\KeyProperty\GuidKeyPropertyObject.cs" ) or at How to generate a sequential and user-friendly identifier field within a business class 
2.  In the Integrated Mode and middle-tier Application Server scenario the newly generated sequence number will appear in the DetailView only after a manual refresh (i.e., it will be empty right away after saving a new record), because the sequence is generated on the server side only and is not passed to the client. You can download a ready test project for these configurations here.
3. You can specify or seed the initial sequence value manually: either by editing the Sequence table in the database or using the standard XPO/XAF means by manipulating the Sequence objects, e.g.:

[C#]
using(IObjectSpaceos=Application.CreateObjectSpace(typeof(Sequence))){Sequencesequence=os.FindObject<Sequence>(CriteriaOperator.Parse("TypeName=?",typeof(E2829).FullName));sequence.NextSequence= 5;os.CommitChanges();}


See also:
How to create multiple sequences based on the a class property value, not one sequence per class type

Question Comments

Added By: Mr. Murat YILMAZ at: 10/7/2012 9:15:18 AM    

Thanks for the example. I developed ISequentialNumber domain component which based on this article and code. Now this sequential number functonatility shon in this example work with domain components and shared parts.

using System;
using System.Collections.Generic;
using System.ComponentModel;

using DevExpress.ExpressApp.DC;
using DevExpress.Persistent.Base;
using DevExpress.Xpo;
using DevExpress.Xpo.Metadata;
using DevExpress.ExpressApp;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;

using MyWay.Xaf.Module;
using MyWay.Xaf.Utils.Sequence;

namespace MyWay.Xaf.Module
{
    [DomainComponent]
    [NavigationItem]
    public interface ISequentialNumber
    {
        #region PROPERTIES

        #region SequentialNo

        [Persistent]
        string SequentialNo
        {
            get;
        }

        #endregion SequentialNo

        #region SequentialNumber
        
        [System.ComponentModel.Browsable(false)]
        [Indexed(Unique = false)]
        long SequentialNumber
        {
            get ;
            set;
        }

        #endregion SequentialNumber

        #endregion PROPERTIES
    }

    [DomainLogic(typeof(ISequentialNumber))]
    public class ISequentialNumberLogic
    {

            public static string Get_SequentialNo(ISequentialNumber instance)
            {
                return "asd" + instance.SequentialNumber.ToString();
            }

            

        private static object syncRoot = new object();
        private static SequenceGenerator sequenceGenerator;

        #region METHODS

        #region PUBLIC METHODS

        #region GenerateSequence

        public static void GenerateSequence(ISequentialNumber instance)
        {
            lock (syncRoot)
            {
                Dictionary<string, bool> typeToExistsMap = new Dictionary<string, bool>();

                foreach (object item in ((XPBaseObject)instance).Session.GetObjectsToSave())
                {
                    typeToExistsMap[((XPBaseObject)instance).Session.GetClassInfo(item).FullName] = true;
                }

                if (sequenceGenerator == null)
                {
                    sequenceGenerator = new SequenceGenerator(typeToExistsMap);
                }

                SubscribeToEvents(((XPBaseObject)instance).Session);
                OnSequenceGenerated(sequenceGenerator.GetNextSequence(((XPBaseObject)instance).ClassInfo), instance);
            }
        }

        #endregion GenerateSequence

        #endregion PUBLIC METHODS

        #region PROTECTED METHODS

        #region OnSaving

        public static void OnSaving(ISequentialNumber instance)
        {
            try
            {
                //base.OnSaving();
                if (((XPBaseObject)instance).Session.IsNewObject(instance) && !typeof(NestedUnitOfWork).IsInstanceOfType(((XPBaseObject)instance).Session))
                {
                    GenerateSequence(instance);
                }
            }
            catch
            {
                CancelSequence(((XPBaseObject)instance).Session);
                throw;
            }
        }

        #endregion OnSaving

        #endregion PROTECTED METHODS

        #region INTERNAL METHODS

        #endregion INTERNAL METHODS

        #region PRIVATE METHODS

        #region AcceptSequence

        private static void AcceptSequence(Session session)
        {
            lock (syncRoot)
            {
                if (sequenceGenerator != null)
                {
                    try
                    {
                        sequenceGenerator.Accept();
                    }
                    finally
                    {
                        CancelSequence(session);
                    }
                }
            }
        }

        #endregion AcceptSequence

        #region CancelSequence

        private static void CancelSequence(Session session)
        {
            lock (syncRoot)
            {
                UnSubscribeFromEvents(session);
                if (sequenceGenerator != null)
                {
                    sequenceGenerator.Close();
                    sequenceGenerator = null;
                }
            }
        }

        #endregion CancelSequence

        #region Session_AfterCommitTransaction

        private static void Session_AfterCommitTransaction(object sender, SessionManipulationEventArgs e)
        {
            
            AcceptSequence(e.Session);
        }

        #endregion Session_AfterCommitTransaction

        #region Session_AfterRollBack

        private static void Session_AfterRollBack(object sender, SessionManipulationEventArgs e)
        {
            CancelSequence(e.Session);
        }

        #endregion Session_AfterRollBack

        #region Session_FailedCommitTransaction

        private static void Session_FailedCommitTransaction(object sender, SessionOperationFailEventArgs e)
        {
            CancelSequence((Session)sender);
        }

        #endregion Session_FailedCommitTransaction

        #region SubscribeToEvents

        private static void SubscribeToEvents(Session session)
        {
            if (!(session is NestedUnitOfWork))
            {
                session.AfterCommitTransaction += Session_AfterCommitTransaction;
                session.AfterRollbackTransaction += Session_AfterRollBack;
                session.FailedCommitTransaction += Session_FailedCommitTransaction;
            }
        }

        #endregion SubscribeToEvents

        #region UnSubscribeFromEvents

        private static void UnSubscribeFromEvents(Session session)
        {
            if (!(session is NestedUnitOfWork))
            {
                session.AfterCommitTransaction -= Session_AfterCommitTransaction;
                session.AfterRollbackTransaction -= Session_AfterRollBack;
                session.FailedCommitTransaction -= Session_FailedCommitTransaction;
            }
        }

        #endregion UnSubscribeFromEvents

        #region OnSequenceGenerated

        private static void OnSequenceGenerated(long newId, ISequentialNumber instance)
        {
            instance.SequentialNumber = newId;
        }

        #endregion OnSequenceGenerated

        #endregion PRIVATE METHODS

        #endregion METHODS
    }
}

Added By: Luis Alberto Santiago at: 2/25/2013 8:06:36 PM    

Hi Mr. Murat YILMAZ, Can yo provide some example to use the class. I am looking it for shared parts

Added By: Andrew Bingham 2 at: 7/8/2013 3:38:51 AM    

I implemented this OK in a Solution

When I eimplmented it in a different solution I got an Exception
"Message: Value cannot be null.
Parameter name: Application"

thrown at:

    public static void Initialize() {
            Guard.ArgumentNotNull(Application, "Application");

Added By: Dennis (DevExpress Support) at: 7/11/2013 3:11:06 AM    

@Andrew: You forgot to add the following code:

public override void Setup(XafApplication application) {
            base.Setup(application);
            SequenceGeneratorInitializer.Register(application);
        }

You will not experience this and similar difficulties if you simply add the reusable module into your solution as per instructions above.

Added By: Carlitos at: 8/23/2014 6:46:05 PM    

Hi,
Is this now supported in Middle-Tier XAF applications?

Thanks,

Carlitos

Added By: Dennis (DevExpress Support) at: 8/25/2014 4:38:12 AM    

We have not performed additional R&D and testing of this particular example in a middle-tier scenario. Moreover, I see technical problems using this particular solution in this configuration, because here we use ExplicitUnitOfWork, which implies that it will be a sole owner of the database connection. Probably, for this configuration, it is better to stick to a standard solution, e.g. using database triggers. 

Added By: Carlitos at: 8/25/2014 9:34:23 AM    

Hi Dennis,
But how does the Middle-tier handle database connections? I thought it would do some sort of connection pooling and manage all client connections?

Why do you think that Triggers are a good alternative?

Carlos

Added By: Dennis (DevExpress Support) at: 8/26/2014 6:14:27 AM    

By default, the middle-tier app server uses ThreadSafeDataLayer to effectively handle requests from multiple clients at the same time. Connection pooling may be used here, but this is not managed by us by default and is rather controller by ADO.NET transparently for a consumer. My main concern here was that in such a multi-user environment it will not be possible to exclusively lock the connection by one user.
A solution at the database level looks more universal as it works at the database level and is irrelevant to whether the app server is used or not. 

Added By: Vishwas Mokashi at: 4/14/2015 11:21:58 AM    

In XAF application I have about 25 various business objects that need to generate unique user friendly sequence numbers in when saved. For example Customer Number, Invoice Number, Order Number, etc. Many users are going to work concurrently and everything should work in transaction.

Which approach should I use, the one in E2620 or E2829?.

I felt E2620 a bit better as I need not to inherit my classes (25 of them) from  UserFriendlyIdPersistentObject as shown in E2829.  

But approach in E2829 is said to be primarily for XAF applications

Added By: Dennis (DevExpress Support) at: 4/15/2015 4:47:25 AM    

@Vishwas: Both E2620  and E2829 demonstrate the same solution using ExplicitUnitOfWork. E2829 is just a bit better integrated with the XAF infrastructure.
If you do not want to inherit from a common base class, I suggest you consider using How to generate a sequential and user-friendly identifier field within a business class, which is simpler to implement and provides similar capabilities without using ExplicitUnitOfWork.

Added By: Vishwas Mokashi at: 4/17/2015 6:54:45 AM    

OK thanks Dennis.

Will simpler approach in "How to generate a sequential and user-friendly identifier field within a business class" handle concurrent users creating same business objects properly?. We can assume about 25 Concurrent users for same business object, with SQL Server DB.

Some users will be accessing system over low banddwidth VPN internet connection. (for Sale Invoice object which needs to generate sequencial Invoice Numbers)

Added By: Dennis (DevExpress Support) at: 4/20/2015 7:58:16 AM    

@Vishwas: Yes, it will. The DistributedIdGeneratorHelper class tries to save a record and repeats its attempts several times until it reaches the maximum number or saves data completely. Check out the corresponding source code for more details on how this works.

    public static class DistributedIdGeneratorHelper {
        public const int MaxIdGenerationAttemptsCounter = 7;
        public static int Generate(IDataLayer idGeneratorDataLayer, string seqType, string serverPrefix) {
            for(int attempt = 1; ; ++attempt) {
                try {
                    using(Session generatorSession = new Session(idGeneratorDataLayer)) {
                        CriteriaOperator serverPrefixCriteria;
                        if(serverPrefix == null) {
                            serverPrefixCriteria = new NullOperator("Prefix");
                        }
                        else {
                            serverPrefixCriteria = new BinaryOperator("Prefix", serverPrefix);
                        }
                        OidGenerator generator = generatorSession.FindObject<OidGenerator>(
                            new GroupOperator(new BinaryOperator("Type", seqType), serverPrefixCriteria));
                        if(generator == null) {
                            generator = new OidGenerator(generatorSession);
                            generator.Type = seqType;
                            generator.Prefix = serverPrefix;
                        }
                        generator.Oid++;
                        generator.Save();
                        return generator.Oid;
                    }
                }
                catch(LockingException) {
                    if(attempt >= MaxIdGenerationAttemptsCounter)
                        throw;
                }
            }
        }Added By: Vishwas Mokashi at: 4/21/2015 6:03:28 AM    

Thanks Dennis


OBSOLETE - How to: Convert the Console Application Server to the Windows Service

How to export Web Dashboard into a PDF document with different filter values on different pages

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.
Question Comments

Added By: Dan Lingwood at: 10/23/2017 5:27:19 PM    So why would you want to go through all this if you can load the pdf file directly with pdfViewer1.LoadDocument(demo.pdf)?

What would be good is to have the option to load from byte array to PdfViewer .  Any code for that?

WPF Report Designer - How to hide properties of reports and their elements

How to implement select/unselect for all rows in a group row in ASPxGridLookup

$
0
0
This example demonstrates how to implement select/unselect for all rows in a group row.

 

First, place ASPxCheckBox and ASPxLabel into the ASPxGridLookup.GridViewProperties.Templates.GroupRowContent template.

Second, set the ASPxCheckBox.Checked property and the client-side ASPxCheckBox.ClientSideEvents.CheckedChanged event in the ASPxCheckBox.Load event handler.

In this example the ASPxLabel.Text is bound in the markup using Two-Way DataBinding.


See also
How to implement select/unselect for all rows in a group row

Question Comments

Added By: Cedric C at: 10/24/2017 6:15:09 AM    I suppose the select all ability is implemented by this part of code:
<GroupRowContent>                         <table>                             <tr>                                 <td>                                     <dx:ASPxCheckBox ID="checkBox" runat="server" OnLoad="checkBox_Load" />                                 </td>                                 <td>                                     <dx:ASPxLabel ID="CaptionText" runat="server" Text='<%# GetCaptionText(Container) %>' />                                 </td>                             </tr>                         </table>                     </GroupRowContent>

But what is meant to do the 'checkBox_Load' callback?

OBSOLETE - How to: Configure a WCF ApplicationServer and win/web client.

How to show map pins using data from ASPxGridView

$
0
0

To show dxMap, it is first necessary to create a div tag with an ID that will be used in code as a container. Then, handle the ASPxGridView's CustomJSProperties event that allows passing a custom array of city names and their coordinates from the server side to the client. After that, use this array in a function that creates a dxMap instance and shows map pins with names of the cities at required coordinates. Handle the client-side Init event to show the map when the page is loaded. To show filtered results, handle the client-side BeginCallback event to set a flag (the "filtering" variable) when the ASPxGridView executes filter commands. Finally, handle EndCallback, which fires only when the flag is set and reset map markers.
dxMap is created in the createMap function on the client side. And then, map properties are set to dxMap's markers option. Iterate through the cities' array stored in the ASPxClientGrid's "cpCities" JS property and create a pins array. After that, assign this array to the markers option using the option method. Refer to the dxMap topic to get more information about dxMap.

For versions older than 17.1, see implementation details below.

Question Comments

Added By: Denis Sikic at: 1/8/2014 9:11:31 AM    

This example does not load for me. The project file is missing.


How to use the ExpressionEditorForm as a stand-alone control

$
0
0

This example demonstrates how to embed the ExpressionEditorForm into the PanelControl and provide a functionality to apply expressions to unbound GridColumns.

Question Comments

Added By: Paul Weiss at: 7/10/2013 8:38:43 PM    

Does this work for Silverlight? I'd like to use the expression editor stand-alone in Silverlight.

Added By: Anders Wang at: 6/24/2015 12:53:08 AM    

Hi,
The GridControl in the sample always no data can be showned. Please correct the example. Thanks.

Added By: Uriah (DevExpress Support) at: 6/24/2015 2:06:39 AM    Hi Anders,

Thank you for pointing us to this problem. The example uses the Access database, which does not support x64 applications. I have fixed the problem by setting the Platform target option to x86 in the project properties.Added By: Anders Wang at: 10/26/2017 7:45:11 PM    
Hi
what is the UnboundColumnExpressionEditorForm equivalent for the new version ExpressionEditor?

How to locate field value cells matching a particular condition (that contains only zero summary values)

$
0
0

The following example demonstrates how to handle the CustomFieldValueCells event to locate a specific column/row header identified by its column's/row's summary values.
In this example, a predicate is used to locate a column that contains only zero summary values. The column header is obtained by the event parameter's FindCell method, and then removed via the Remove method.

How to print/export XtraReport in an ASP.NET WebForms application without showing a report preview

$
0
0

This example demonstrates how to print/export XtraReport without displaying a report preview and using the preview's printing/exporting functionality. 

The main idea of this approach is to export XtraReport into the page's Response by using one of its ExportTo... methods.
To print the report, export it to the PDF format and enable the ShowPrintDialogOnOpen option in the export options. Then export this PDF to a page's Response with the Content-Disposition header set to the "inline" value. In this case, this PDF will be opened by the browser's PDF plugin. To avoid opening the PDF viewer in the browser's window, export the PDF to a separate iframe. In this case, only the print dialog will be displayed.

See also:
E454: How to print a report without displaying it in a web application
T569785: How to print/export XtraReport in an ASP.NET MVC application without showing a report preview

How to print a report without displaying it in a web application

$
0
0

This example illustrates the approach of printing report document directly, via Adobe PDF web browser plug-in.
This can be done by sending the exported XtraReport document via the Page.Response.OutputStream.Write method, and setting the PdfExportOptions.ShowPrintDialogOnOpen property to True.

See also:
How to print/export XtraReport in an ASP.NET WebForms application without showing a report preview

How to print/export XtraReport in an ASP.NET MVC application without showing a report preview

Question Comments

Added By: M Abo Habiba at: 8/28/2013 2:08:29 PM    

can i print it without export to pdf ?

Added By: Alex (DevExpress Support) at: 8/29/2013 2:54:42 AM    

Hi,

The direct printing approach is not supported in a Web application because the web server does not have direct access to the printer installed on the client's machine.

Added By: M Abo Habiba at: 9/2/2013 12:38:48 PM    

I face a problem when i try to print using pdf (Arabic Unicode)
i tried to print it using java script but when page load it show the print dialog before report displayed can detect after print in java script or any way else
thanx

Added By: Alex (DevExpress Support) at: 9/3/2013 1:29:36 AM    

Hi,

If possible, create a separate ticket in Support Center and provide your test application for further examination. We will check for a suitable solution.

Added By: FSzymanska at: 3/5/2014 3:34:09 AM    

Hi,

I have run your example. Everything works fine when English chars are used. But when I put poloish chars like 'ś' , ć' in the report content thay are printed badly. Looks like problem with encoding. Can you please help me?

Added By: M Abo Habiba at: 4/24/2016 9:19:51 AM    i used this example to print put it's appear look like pdf viewer in browser Added By: Dmitry Tok (DevExpress Support) at: 4/25/2016 5:27:42 AM    

Hello,

This behavior depends on the PrintUsingAdobePlugIn property value. Please review the Printing in Web help topic for details.

Thanks,
Dmitry

Added By: Mike Bowen 1 at: 6/10/2016 2:44:54 AM    Are there known issues with this and printing with Microsoft Edge?

The print dlg never shows.
Edge 25.10586
Added By: Vasily (DevExpress Support) at: 6/10/2016 8:02:03 AM    

Hello Mike,  

I've created a separate ticket on your behalf (T390890: How to print a report without displaying it in a web application in Edge browser). It has been placed in our processing queue and will be answered shortly.

How to manually provide vector items from WKT

$
0
0
This example demonstrates how to manually provide vector items from the SQL Geometry Well-Known Text.
Question Comments

Added By: william sutphin 1 at: 10/27/2017 12:36:20 PM    So how do associate labels, etc?
Viewing all 7205 articles
Browse latest View live


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