Quantcast
Viewing all 7205 articles
Browse latest View live

How to auto-select the first item, when changing the group in the navigation control

By default, XAF doesn't execute the first navigation item when changing the group. But, you can easily change this behavior by customizing the navigation control, and reusing the functionality of the ShowNavigationItemController.

This example demonstrates how to write a controller that will do this. This controller is managed by the attribute. By default, it doesn't select the first navigation item in the group.

These help topics will be also very helpful:
How to: Change Navigation Control Appearance
ShowNavigationItemController Class
Built-in Controllers and Actions


How to implement accent-insensitive filtering in ASPxGridView bound to Server Mode data source

When ASPxGridView is bound to a server mode data source, all data operations are performed on the database server: Binding to Large Data (Database Server Mode)?. Thus, results depend on database settings. For instance, filtering data with diacritic signs depends on the default collation of your data server:
[CodeProject.com] Configuring SQL Server Accent-Insensitivity
[Stackoverflow.com] Questions about accent insensitivity in SQL Server (Latin1_General_CI_AS)?

In other words, the first solution to achieve accent-insensitive filtering when the grid is bound to the server mode datasource is to change collation on the server. 
Another solution is to create a custom filter operator by implementing ICustomFunctionOperator and  ICustomFunctionOperatorFormattable interfaces and modify a filtering request to the database in the ICustomFunctionOperatorFormattable.Format method:

[C#]
stringICustomFunctionOperatorFormattable.Format(TypeproviderType,paramsString[]operands){varoperand=string.Format("N'%{0}%'",operands[0].Split('\'')[1]);returnstring.Format("{0} COLLATE SQL_Latin1_General_CP1_CI_AI LIKE {1} ",operands[1],operand);}
[VB.NET]
PrivateFunction ICustomFunctionOperatorFormattable_Format(ByVal providerType As Type, ParamArrayByVal operands() AsString) AsStringImplements ICustomFunctionOperatorFormattable.FormatDim operand = String.Format("N'%{0}%'", operands(0).Split("'"c)(1))ReturnString.Format("{0} COLLATE SQL_Latin1_General_CP1_CI_AI LIKE {1} ", operands(1), operand)EndFunction

 

In this case, the accent-insensitive collation is applied only for filtering. Note that this approach is not supported by LINQ-based ORMs.

This example demonstrates how to implement accent-insensitive filtering in Auto Filter Row when ASPxGridView is bound to XpoDataSource with Server Mode enabled. To test the example, download the solution to your local machine.

See Also:
How to make the Grid's filter to be a case- and accent-insensitive in Server Mode
E4836: How to create a custom ASPxGridView's filter insensitive to the number of spaces and punctuation

ASPxGridView - How to apply jQuery selectors to DataCells' content

This example is an illustration of the K18561: Using jQuery / jQuery UI libraries with DevExpress ASP.NET Controls / MVC Extensions KB Article. Refer to the Article for an explanation.

This example illustrates how to attach jQuery selectors to ASPxGridView DataCells' content and keep selectors' functionality after grid's rendering is completely updated via a callback.

Usually when it is necessary to attach jQuery selectors to any existing HTML content, it is recommended to use the $(document).ready function that can be used for handling the state when the DOM is fully loaded. When some jQuery selectors are attached to the HTML content inside ASPxGridView, these selectors are stopped after the grid's rendering is completely updated via a callback (and the entire grid's HTML content is re-created on the client side). It is necessary to execute the required jQuery selectors explicitely by handling the client-side ASPxClientGridView.EndCallback event that is raised on the client side after a callback's server-side processing has been completed. It is also recommended to handle the client-side ASPxClientControl.Init (ASPxClientGridView.Init) event (rather than the use of the jQuery $(document).ready function) to enure that the corresponding client-side control's programmatic object is initialized.

Refer to the Client-Side Functionality Overview topic in our documentation to learn more about the common concepts of the client-side API of the DevExpress ASP.NET Controls.

Question Comments

Added By: Suraj Babu at: 9/6/2012 9:06:18 PM    

Thank You Very Much. I was facing same problem and it got resolved.

How to load an excel file to the server using ASPxUploadControl and display its data in ASPxSpreadsheet

This example shows how to load an excel file from your computer to the server using ASPxUploadControl and then display its data in ASPxSpreadsheet.
To do this, you first need to place the ASPxSpreadsheet and ASPxUploadControl controls on a page and, secondly, handle the ASPxSpreadsheet.Load event and both the server-side and the client-side ASPxUploadControl.FileUploadControl events.
After uploading the excel file from your computer, save it in the "~/XlsTables/" directory using the ASPxUploadControl.FileUploadControl event handler on the server-side. You may choose any filename and then save it in the Session["FileName"] object to use later.
In the ASPxSpreadsheet.Load event handler you need to check the value of the Session["FileName"] object. If it's null, do nothing. Otherwise use the ASPxSpreadsheet.Open method with this name as a parameter.

See also: How to load an excel file to the server using ASPxUploadControl and display its data in ASPxGridView

How to: draw a custom legend marker for a series

This example demonstrates one of possible ways to use the CustomDrawSeries event. In this sample the event is used to modify the legend markers of bar series.
Question Comments

Added By: Ralf Boscher at: 7/29/2016 4:51:26 AM    Hello,

the example only draws rectangles - how to draw:
 
DashStyle.Dash

DashStyle.DashDot

DashStyle.DashDotDot

DashStyle.Dot

DashStyle.Dash

Thank you
Ralf

Added By: Ralf Boscher at: 7/29/2016 4:53:04 AM    Hello,
how to draw dots, dashdot or DashDotDot etc.
Thank you
Ralf Added By: Rоman K (DevExpress) at: 7/29/2016 5:25:59 AM    Hello, Ralf.

In this example, legend markers are images rendered using the System.Drawing.Graphics class. To draw lines with the required DashStyle, use the following approach.
[C#]
graphics.DrawLine(newPen(e.LegendDrawOptions.Color){DashStyle=isSelected?System.Drawing.Drawing2D.DashStyle.DashDotDot:System.Drawing.Drawing2D.DashStyle.Dash,Width= 4},newPoint(0,totalHeight/ 2),newPoint(totalWidth,totalHeight/ 2));

Feel free to contact us if you need further assistance.

How to provide GridControl Master-Detail extension with MVVM capabilities

This example illustrates how to add MVVM capabilities to the Master-Detail functionality. In this example we have created the MasterDetailMVVMHelper class that introduces the ExpandedMasterRowsSource attached property. This property is intended to be attached to GridControl and allows controlling details' expanded state via a collection in a view model.

Here is a sample XAML that illustrates how to attach this property to GridControl and make it bound to the ExpandedItems collection:

[XAML]
<dxg:GridControlmy:MasterDetailMVVMHelper.ExpandedMasterRowsSource="{Binding ExpandedItems}"Name="gridControl1"ItemsSource="{Binding Data}">

 
Now, by adding a couple of data objects to the ExpandedItems collection, you can expand corresponding rows in GridControl:

[C#]
ExpandedItems.Add(Data[1]);ExpandedItems.Add(Data[10]);
[VB.NET]
ExpandedItems.Add(Data(1)) ExpandedItems.Add(Data(10))

An important note: The collection being bound to the ExpandedMasterRowsSource must be an implementation of the INotifyCollectionChanged interface, otherwise this functionality will not operate as expected.

Question Comments

Added By: Ipek Guven at: 6/26/2012 11:52:42 PM    

This solution is not working with the latest native Master-Detail feature in Vol 12.1. Can you upgrade the solution or provide a new one for the latest release?
Thanks in advance.
Ipek

Added By: James J Sullivan Sullivan at: 8/13/2012 6:26:49 PM    

Ipek, you might want to reference the Grid.Extensions dll as well.
http://www.devexpress.com/Support/Center/p/Q383850.aspx

Added By: Neeraj Thakur at: 1/31/2016 10:27:09 PM    

Is there any same example  for winforms
thanks Neeraj

Added By: Ivan (DevExpress Support) at: 1/31/2016 11:31:48 PM    

Hello Neeraj,

I have extracted your question to a separate ticket - How to obtain expanded rows when the Master-Detail functionality is used - and passed it to our WinForms team. That ticket is in our processing queue, and we will update it once we have any news.

How to dynamically pass XtraReport parameters into the underlying SqlDataSource to perform server-side filtering

This example shows how to dynamically add a parameter to XtraReport, compose FilterString in the SqlDataSource and use XtraReport's parameters to filter data in the SqlDataSource.

Question Comments

Added By: Janvic Castrejon at: 7/31/2016 10:55:20 PM    Hi!, when I try this code, I have the next exception: "NullReferenceException" in the line of "tq.Parameters.Add(queryParameter1);"
How do I solve it?
I need to pass a parameter in the code, for when loading the report, this already has the necessary information.Added By: Jannet (DevExpress Support) at: 8/1/2016 12:40:17 AM    

Hello,

I've created a separate ticket on your behalf (T409623: The T158360 example - "NullReferenceException" in the line of "tq.Parameters.Add(queryParameter1);"). It has been placed in our processing queue and will be answered shortly.

How to Add the Analyze Action to List Views

To add the capability to analyze data in your application, the eXpressApp Framework supplies the Pivot Chart Module. To have the Analysis functionality in an application, you should simply add this module and the built-in Analysis business class to the application. In this instance, the navigation control will contain the Analysis item and end-user will be able to create Analysis objects. However, you may need to provide the ability to create an Analysis object from any List View, setting the new Analysis object's ObjectType property to the object type of the List View. This example demonstrates how to accomplish this task.

For details, refer to the How to: Add the Analyze Action to List Views topic in XAF documentation.

Question Comments

Added By: Paul Kubb at: 7/31/2016 1:46:04 AM    I have had an error :


 e.ShowViewParameters.CreatedView = Application.CreateDetailView(objectSpaceInternal, obj);

[C#]
Anexceptionoftype'System.ArgumentException' occurredinDevExpress.ExpressApp.v16.1.dllbutwasnothandledinusercodeAdditionalinformation:Anerrorwithnumber 1096 hasoccurred.Errormessage:TheObjectSpacehasalreadybeenassignedtoanotherrootview:'DetailView,ID:Analysis_DetailView'.ThiserroroccursonlywhenyoutrytoassignanObjectSpacethatisalreadyusedbyarootViewtoanotherrootview.Forinstance,youmayreceivethiserrorwhenusingtheXafApplication.CreateDetailView/CreateListViewmethodsinaViewControllerandpassingtheView.ObjectSpaceobjectasaparametertothesemethodswhentheView.IsRootpropertyistrue.Toavoidthiserrorit'ssufficienttopassanewObjectSpaceinstancecreatedviatheXafApplication.CreateObjectSpacemethodinthesemethods,orcreatenon-rootViewsbypassingacorrespondingparametertothesemethods.

any suggestion please?

Added By: Paul Kubb at: 7/31/2016 2:00:39 AM    Seems like it is required to add IsRoot to false into its parameter explicitly.

e.ShowViewParameters.CreatedView = Application.CreateDetailView(objectSpaceInternal, obj, false); 

after adding it, Save functionality is disallowedAdded By: Konstantin B (DevExpress) at: 8/1/2016 7:14:45 AM    Hello Paul,

Would you please provide exact steps to reproduce this error? I tried the E389 example, and no error occurred when I clicked Analyze.

How to bind the Web Dashboard Designer to Excel Data sources

This example shows how to create an Excel data source and select the A1:L1000 range of cells located on the SalesPerson worksheet.

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

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.


Image may be NSFW.
Clik here to view.



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. 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);//!!!...}

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, 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));


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. This solution is not yet tested in the middle-tier and SecuredObjectSpaceProvider scenario and most likely, it will have to be modified to support its specifics.
3. The sequential number functionality shown in this example does not work with shared parts (a part of the Domain Components (DC) technology) in the current version, because it requires a custom base class, which is not allowed for shared parts.

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

How to highlight the focused editor in DetailView

Scenario
In this example, it is demonstrated how highlight focused editors in an editable DetailView for both Windows and the Web:

Image may be NSFW.
Clik here to view.

Additionally, the following Model Editor extensions are implemented for more convenience:
 - The HighlightFocusedLayoutItem attribute at the Application | Options node level allows you to control this functionality globally per application via the Model Editor.
 - The HighlightFocusedLayoutItem attribute at the Views | DetailView node level allows you to customize only certain DetailViews via the Model Editor

Image may be NSFW.
Clik here to view.


Steps to implement
1. Modify YourSolutionName.Module/Module.xx file as shown in the WinWebSolution.Module\Module.xx file of this example.
Note: The approach from the eXpressApp Framework > Concepts > Application Model > Extend and Customize the Application Model in Code article is used here.

2. Copy the WinWebSolution.Module\HighlightFocusedLayoutItemDetailViewControllerBase.xx file into the YourSolutionName.Module project.
Note: The approaches from the eXpressApp Framework > Concepts > Application Model > Access the Application Model in Code and Controller.Active Property articles is used here.

3. Copy the WinWebSolution.Module.Win\WinHighlightFocusedLayoutItemDetailViewController.xx file into the YourSolutionName.Module.Win project.
Note: In Windows Forms applications, the functionality is provided with the help of the LayoutControl and its HighlightDisabledItem and AllowItemSkinning options. The approach from the eXpressApp Framework > Concepts > UI Construction > View Items Layout Customization article is used to access LayoutControl.

4. Copy the WinWebSolution.Module.Web\WebHighlightFocusedLayoutItemDetailViewController.xx file into the YourSolutionName.Module.Web project. Then copy the WinWebSolution.Web\E2106.js file into the YourSolutionName.Web project.
Finally, add the <script type="text/javascript" src="E2106.js"></script> line into the <head> element of your YourSolutionName.Web\Default.aspx file.
Note: In ASP.NET applications, the functionality is implemented manually as per How to highlight a focused editor via client-side scripting via client-side events provided by our ASP.NET editors. The approach from the eXpressApp Framework > Getting Started > Comprehensive Tutorial (MainDemo Application) > Extend Functionality > Access Editor Settings article is used to access PropertyEditor controls.


IMPORTANT NOTES
It is possible to register your JavaScript functions at runtime via the DevExpress.ExpressApp.Web.WebWindow.CurrentRequestWindow.RegisterXXXScript methods called from a Controller when it is activated or when page controls are created. Refer to the How to automatically refresh data in a View after a certain period of time on the Web article for an illustration of this approach.

Question Comments

Added By: tzanis tasos at: 1/27/2015 11:52:22 AM    

Hello,
In version V2014 14.2.4.0 this sample not work on web. It works only for combobox and not for other controls.
When i run the sample in debug mode, the existingHandler return empty string when eventName="GotFocus"
string existingHandler = control.GetClientSideEventHandler(eventName);

Added By: Dennis (DevExpress Support) at: 1/28/2015 9:14:33 AM    @Tzanis: Thanks for your report. I will answer you in T201753.Added By: Carlitos at: 3/15/2015 4:16:47 PM    

I like this. Does it work when using E2034,?

Added By: Dennis (DevExpress Support) at: 3/16/2015 5:26:02 AM    @Carlitos: No, because the E2034 example disables skinning.Added By: Abel Acosta 1 at: 4/30/2015 10:46:42 AM    

Hi DevExp Team,

I Have tried to implement this nice functionality, its works fine while i am running both xaf windows form and web application, from Visual Studio. However, when i deploy the windows form  application its fail.

it says.

Exception Occurs while assigning the 'DetailView, ID: BussinessClass_DetailView' view to WinWindow
Unabled To Cast object of type 'ModelDetailView' to type 'Solution.Module.IModelDetailViewHightlightFocusedLayoutItem'.

What i am missing or doing wrong? The web application works fine even deployed.

Added By: Dennis (DevExpress Support) at: 4/30/2015 1:54:57 PM    @Abel: According to the error message you have missed the first step from the Steps to Implement section above.

How to customize the New Report Wizard (introduced in the 2014 vol.1 release) in the End-User Designer

This sample illustrates how to customize the wizard in the End-User Designer.

See also:
Data Source Wizard – How to Replace the Standard Query Builder
Data Source Wizard - How to customize the list of data providers

Question Comments

Added By: Jon 9 at: 10/23/2014 5:08:13 AM    

Is there any further documentation on how to customize the new report wizard. This sample code would really benefit from some comments... I can see why it has attracted down votes - it isn't really sufficient.

Added By: Ingvar (DevExpress Support) at: 10/23/2014 6:28:50 AM    Hi Jon,

I agree with you that we need to prepare documentation related to our Report Wizard. I have created a separate request and forwarded it to our developers. You can track our progress in the following ticket:
Documentation - Provide informative help topics on how to customize Report Wizard introduced in v14.1Added By: Jon 9 at: 10/23/2014 6:37:12 AM    

Great, thanks! Will look forward to it.

Added By: Scott Bogash 1 at: 12/5/2014 9:19:21 AM    

Can you please update this example to work with v2014 vol 2.3.  Thank you

Added By: Scott Bogash 1 at: 12/30/2014 11:43:37 AM    

Can you please update this example to work with v2014 vol 2.3.  Thank you

Added By: Andrew L (DevExpress Support) at: 12/30/2014 1:09:06 PM    

Hello Scott,

We are working hard on this problem and we will do our best to prepare this sample to work with our next minor release, 2014.2.4.

Added By: Andrew L (DevExpress Support) at: 1/21/2015 1:29:16 AM    

Hello Scott,

We have found an issue in our 2014.2.4 release, which prevents us from publishing the sample. Please install the hot fix provided in the The Wizard Customization example (T140683) cannot be compiled thread and review the updated samples (in that thread).

Added By: Michael Vasiliev at: 3/24/2016 9:19:30 AM    Hi guys.

Can you please tell me how can I create a custom view for custom wizard?
I noticed that the views in the example (ChoosePersonsPageView2) were created  in Designer.
And they have specific controls (DevExpress.DataAccess.UI.Wizard.BackButton).
But I can't find them in Toolbox.Added By: Jannet (DevExpress Support) at: 3/24/2016 10:20:03 AM    

Hello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T360326: How to create a custom view for custom wizard. This ticket is currently in our processing queue and will be addressed shortly.

Added By: Chad at: 4/29/2016 2:19:26 PM    Can you please fix the file Person.vb to remove the New Object cast..

[VB.NET]
PublicFunction GetStaticPersons() As IList(Of Person)ReturnNew List(Of Person)({New Person() With {.FirstName = "John", .SecondName = "Abbot"}, New Person() With {.FirstName = "Paul", .SecondName = "Bass"}, New Person() With {.FirstName = "George", .SecondName = "Chance"}})EndFunction


Added By: Dmitry Tok (DevExpress Support) at: 5/2/2016 4:03:45 AM    

Hello Chad,

Thanks for pointing out this issue to us. 
I have fixed the corresponding part of the provided Code Example per your request. 

GridView - How to use GridLookup in EditForm in multiple selection mode

Starting with v15.1, GridLookup can be automatically bound to a model field that returns an array of values (see  DevexpressEditorsBinder - Support binding multiple values selected in MVC editor extensions to a Model's collection-type property)
This example illustrates how to use GridLookup in a multiple selection mode (SelectionMode is Multiple) as a GridView editor. The main idea is to use the MVCxGridViewColumn.SetEditItemTemplateContent method to place GridLookup in EditForm. The same approach will work for a custom EditForm (GridViewSettings.SetEditFormTemplateContent) as well.

Note that prior to version 16.1.6, the GridLookupExtension.Bind method doesn't automatically select required keys. It's necessary to assign a delegate method to the PreRender property to manually select the values using the GridViewSelection.SelectRowByKey method. Starting with version 16.1.6, it is sufficient to pass values to bind/select to the GridLookupExtension.Bind method.

[C#]
//Prior to version 16.1.6 onlysettings.PreRender=(s,e)=>{MVCxGridLookuplookup=sasMVCxGridLookup;for(inti= 0;i<Model.TagIDs.Length;i++)lookup.GridView.Selection.SelectRowByKey(Model.TagIDs[i]);};
[VB.NET]
'Prior to version 16.1.6 only settings.PreRender = Sub(s, e)Dim lookup As MVCxGridLookup = TryCast(s, MVCxGridLookup)For i AsInteger = 0 To Model.TagIDs.Length - 1 lookup.GridView.Selection.SelectRowByKey(Model.TagIDs(i))Next iEndSub

In order to use client-side unobtrusive JavaScript validation with GridLookup, it's necessary to pass a correct model instance to a partial view. This instance should be of the same type as an item of the collection bound to GridView.

Controller:

[C#]
publicActionResultGridLookupPartial(int?KeyParameter){varmodel=GetModelInstanceByKey(KeyParameter);returnPartialView(model);}
 
[VB.NET]
PublicFunction GridLookupPartial(ByVal KeyParameter?AsInteger) As ActionResultDim model = GetModelInstanceByKey(KeyParameter)Return PartialView(model)EndFunction

 PartialView:

[C#]
@Html.DevExpress().GridLookup(settings=>{settings.Name=PropertyName;}).BindList(...).Bind(Model.PropertyName).GetHtml()
[VB.NET]
@Html.DevExpress().GridLookup(Sub(settings) settings.Name = PropertyNameEndSub).BindList(...).Bind(Model.PropertyName).GetHtml()

See also: 
GridView - How to use GridLookup with single selection mode in EditForm

Web Forms:
How to use two-way data-bound ASPxGridLookup in edit form of ASPxGridView to edit data
How to use ASPxGridLookup in multiple selection mode as the ASPxGridView editor

How To: Implement a Custom Route Provider

This example demonstrates how create a custom route provider and use it to calculate a route between two geographical points.

How to localize DevExtreme widgets using Globalize 1.X when the Knockout approach is used

To localize DevExtreme widgets, do the following:


- Link required dictionaries as described in the following help topic:
Link Dictionaries

Note that the order of references is important.


- Reference the DevExtreme localization script:
Use Predefined Dictionaries 

- Initialize your application after setting the locale:

[JavaScript]
$.when(...}).then( Globalize.load).then(function(){ Globalize.locale('de');// Initialize your application here ko.applyBindings(viewModel, document.getElementById("demo"));});

Important: Call the ko.applyBindings method only after setting a page locale.

For a more detailed description, refer to the following help topic:


Localization 

See also:
Extend Predefined Dictionaries
Globalize.formatMessage

How to define a custom cell template that allows performing data editing

How to bind GridView with standard in-memory data sources (DataTable, List)

This example illustrate how to bind the MVC GridView Extension with the standard in-memory data sources:

- The ADO.NET DataTable - DataTableDataBinding View / DataTableDataBindingPartial Partial View;

- The Typed List (List<T>) - TypedListDataBinding View / TypedListDataBindingPartial Partial View.


The GridView's definition contains:

- Set of Data Columns whose values are retrieved from the underlying datasource (the /*Data-Bound Columns*/ section);

- A single Unbound Column (the /*Unbound Columns*/ section) whose values are computed based on the bound columns' values (the /*Unbound Column Calculating*/ section).


Both data sources (Models) have the same set of fields. These Models are defined within the /Models/Model code file.

See Also:
E3983: GridView - How to edit in memory data source
E3998: GridView - How to specify a custom EditForm Template

Question Comments

Added By: Lori Post at: 1/22/2013 7:43:28 AM    

How would this be done with an IQueryable datasource? I'm using the BindToLinq method to deal with large amounts of data. I need an in memory collection since I will be modifying items in an in memory collection based on updates to the list, and at the very end there will be a second page which will be a confirmation showing the changes in the grid and whether the user would like to continue with the changes.

Added By: Majid Fadavi at: 8/4/2016 1:29:15 AM    I use your sample code and load my DataTable To grid. but when i do any action(click on column header or filter or click pager, ...)
loading appear and gridview locked.
and the action that set in settings.CallbackRouteValues don't fire. Added By: Mike (DevExpress Support) at: 8/4/2016 1:30:22 AM    

Hello,

I've created a separate ticket on your behalf (T411144: GridView - Loading Panel hangs after callback). It has been placed in our processing queue and will be answered shortly.

How to generate a sequential and user-friendly identifier field within an XPO business class

Scenario

Orders, articles or other business entities often require that you have user-friendly Id or Code fields that end-users can memorize and use during phone conversations. They are usually sequential, but some gaps can be allowed as well (e.g., when an order is deleted). Refer to this StackOverFlow thread for more information on this common scenario, and a possible implementation.

Steps to implement

1. Add a new business class to your platform-agnostic module, and  call the static DevExpress.Persistent.BaseImpl.DistributedIdGeneratorHelper.Generate method from the AfterConstruction, OnSaving or other appropriate places within your persistent class or even Controller as shown in the Solution2.Module\BusinessObjects\Order.xx file. Depending on your business requirements, you can implement a readonly persistent or editable property where the generated value will be stored as well as check various conditions before generating the next sequence (e.g., string.IsNullOrEmpty(currentSequenceProperty) - to avoid double assignments, Session.IsNewObject(this) - to check whether the object is new, !(Session is NestedUnitOfWork) - to check whether the object is being saved to the database and not to the parent session, security system checks as per this blog post, etc.)

2. Build your platform-agnostic project and double-click on the Solution2.Module\Module.xx file to invoke the Module Designer;

3. Refer to the Exported Types section within the designer and expand the Referenced Assemblies | DevExpress.Persistent.BaseImpl node;

4. Select and press the space bar on the OidGenerator node to include this persistent type into the business model of your module:
Image may be NSFW.
Clik here to view.

 

IMPORTANT NOTES
1. The DistributedIdGeneratorHelper class demonstrated in this solution creates the IDGeneratorTable table to store the information about the last sequential number of a type. You can learn more on how this works from its source code at "C:\Program Files (x86)\DevExpress 1X.X\Components\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl\IDGenerator.cs".
Although this particular solution is simpler to implement and maintain (as it uses built-in XAF classes) than 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 (XAF) example, it is pretty safe and should also work in the most typical business scenarios (except for the middle-tier Application Server scenario, because the Session.DataLayer property is not initialized in this case).
2. If you have validation rules for your business class, the OnSaving method (and thus the sequence generation) is called only after all validation is passed. However, in rare cases, if a database related error is thrown during the first save and then the form is re-saved, the OnSaving method may be called again and a new sequence can be generated. This may lead to gaps in sequential numbers, which is not always allowed by business requirements (e.g., government regulations). To avoid this, you can use a more complicated solution from 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 (XAF) example or implement a database-level solution to handle such situations (e.g., using triggers).

3. You can find functional EasyTest scripts for this scenario in the Solution2.Module\FunctionalTests\E4904.ets file.

Question Comments

Added By: Gareth- at: 10/2/2013 5:58:17 AM    

Thanks, works perfectly - I've seeded the ID by manually changing the [Oid] in the IDGeneratorTable, do I need to worry about the [OptimisicLockField] or will this update automatically?

Added By: Dennis (DevExpress Support) at: 10/2/2013 7:10:50 AM    

@Gareth: No, you do not need to care about the OptimisticLockField.

Added By: MohammedFarooq at: 12/2/2013 1:07:31 AM    

Hi,

The code is really helpful but it increments the value of code even if the record is deleted! How can we stop the code to increase its value when a record is deleted?

Added By: MohammedFarooq at: 12/2/2013 1:25:16 AM    

I manage to figure out the solution. I have just added the IsDeleted checking and it worked like a charm!!!

    Protected Overrides Sub OnSaving()
        If (Not IsDeleted) Then
             Me.codeCore = String.Format("N{0:D6}", DistributedIdGeneratorHelper.Generate(Me.Session.DataLayer, Me.GetType().FullName, String.Empty))
        End If
        MyBase.OnSaving()
    End Sub

Added By: Dennis (DevExpress Support) at: 12/2/2013 1:26:50 AM    

@Mohammed: Yes, your solution is correct. I will consider updating this example accordingly. Thanks for your input in this regard.

Added By: rushdan . at: 11/6/2014 12:02:48 AM    

Hallo

I do not understand about explanation. What I know is, after I run the application, then save the data , it will execute Code number automatically.

Is it this example to show how to execute auto increase number ? Thanks

Added By: Dennis (DevExpress Support) at: 11/6/2014 2:00:43 AM    

@Rushdan: With the current implementation, the generation code is executed when the persistent object is being saved (OnSaving). I do not quite understand your last question. The functionality implemented in this example is well-detailed in the description and it can also be seen from simple code.

Added By: Andrew Bingham 2 at: 2/5/2015 12:40:25 AM    

"override its AfterConstruction method, as shown in the Solution2.Module\BusinessObjects\DomainObject1.xx file"

1. I cannot find the DomainObject1 file in the sample
2. The only BusinessObject is Order.cs which does not have an AfterConstruction method
3. What code need to go in AfterConstruction method?
4. What are the advantages / disadvantages compared to E2829?

Added By: Dennis (DevExpress Support) at: 2/5/2015 12:47:04 AM    @Andrew: Thanks for your feedback.
1-3. I've corrected this misprint in the description. 
3. This particular solution is simpler to implement than E2829.Added By: Vishwas Mokashi at: 4/21/2015 8:52:32 AM    

Is there any provision so that we can restart the Sequence Number after say an Year is completed?. Also, any way to give the start number for the sequence?.

Added By: Dennis (DevExpress Support) at: 4/21/2015 8:57:35 AM    

@Vishwas: Sure, you can do this. Technically, the information about the last sequence number is stored in the Oid column of the IDGeneratorTable table with the help of the OidGenerator persistent class. You can modify this data using either ADO.NET or XPO means.

Added By: Vishwas Mokashi at: 4/21/2015 9:02:11 AM    

Ok thanks Dennis...will try

Added By: MohammedFarooq at: 10/14/2015 2:37:53 AM    

Dear Dennis,

I have applied this logic in my project which also has validation enabled. Now the issue is, if the validation of the document fails while saving the new number is generated. And when the user saves the document again then a new number is generated as well.

Added By: Dennis (DevExpress Support) at: 10/14/2015 2:58:59 AM    @Mohammed: The original example has the if(string.IsNullOrEmpty(Code))  check that prevents multiple generations. Have you applied this code in your project? If this does not help, submit a separate ticket and attach your problematic sample so we can assist you further.Added By: MohammedFarooq at: 10/14/2015 5:03:57 AM    

You hit a bull's eye! I didn't have the  if(string.IsNullOrEmpty(Code)) in my code.

Was it added recently? Because i followed this example before and somehow i missed it.

Added By: Dennis (DevExpress Support) at: 10/14/2015 5:18:38 AM    You're always welcome. AFAIK, I added it a year ago or so.Added By: Paul Kubb at: 3/16/2016 2:14:58 AM    Would you please describe more in detail about serverprefix table? how and when to use it?
I cannot find any documentation about it also.Added By: Dennis (DevExpress Support) at: 3/17/2016 1:57:56 AM    

@Paul: It was a mistake in the original description, because this table is actually unused by the DistributedIdGeneratorHelper class. Please accept my apologies for the confusion. As for the "string serverPrefix" parameter of the Generate method, it allows you to run several sequences in parallel. Refer to the "C:\Program Files (x86)\DevExpress 1X.X\Components\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl\IDGenerator.cs" source file for more details.

Added By: Paul Kubb at: 8/4/2016 9:44:09 AM    I have read a source file and have several questions aboud DistributedIdGeneratorHelper.Generate():

1.  it seems like you intend to create a separate new session, attempt to save it to the database separately until success and return its Oid. Why can't we use the bo's existing session here?

2. by this design, do you intend to avoid some multi-user problem or something? if so, please explain why having a separate session will overcome it

3. if the OidGenerator is saved successfully in a separate session but the main bo's save event is dead, will the OidGenerator's save event be rolled back? or will we have a jumpy running number instead?

thanks in advance

How to create a custom GridControl that represents columns horizontally in a way similar to the WinForms VerticalGrid control

This example demonstrates how to create a GridControl descendant with horizontally oriented columns.

To use it, simply add the VerticalGridControl.xaml and VerticalGridControl.xaml.cs files in your project.

In addition, this example demonstrates how to customize grid cells using data templates.

Question Comments

Added By: Prashant Patel 7 at: 5/8/2013 11:44:19 PM    

How can we View Stackpanel as fullscreen mode in wpf window ?

Added By: AKN at: 12/12/2013 12:01:51 PM    

Hi, is there any way of showing TotalSummary in this control?

Added By: Chris Schiefer at: 7/18/2014 7:44:04 AM    

When I updated to v2014 vol 1.5, the event for CustomUnboundColumnData is never fired and the cells never present any data.  It looks like the grid is displaying the correct number of rows and columns, but the data isn't populated.

Added By: Michael Ch (DevExpress Support) at: 7/18/2014 11:41:47 AM    

Hello,

To process your recent post more efficiently, we copied it to a separate ticket created on your behalf: T131266: The E4630 example doesn't work correctly after updating to v2014 vol 1.5.
This ticket is currently in our processing queue. We will post to it as soon as we have any updates.

Added By: A Narang at: 8/4/2016 10:48:28 AM    Hi, Is this supposed to show you row labels? First row is date but what if I wanted to show the label "Birth Date" as a row label in the first column of the grid. is that doable?Added By: Michael Ch (DevExpress Support) at: 8/4/2016 11:56:22 AM    

Hello,

I've created a separate ticket on your behalf (T411462: How to show row labels). It has been placed in our processing queue and will be answered shortly.

How to localize DevExtreme widgets using Globalize 1.X when the Angular approach is used

To localize DevExtreme widgets, do the following:


- Link required dictionaries as described in the following help topic:
Link Dictionaries

Note that the order of references is important.


- Reference the DevExtreme localization script:
Use Predefined Dictionaries 

- Initialize your application after setting the locale:

[JavaScript]
$.when(...).then( Globalize.load).then(function(){.. Globalize.locale('de'); angular.bootstrap(document, ['dxApp']);});

Important: Call the angular.bootstrap method only after setting a page locale.


For a more detailed description, refer to the following help topic:


Localization 

See also:
Extend Predefined Dictionaries
Globalize.formatMessage
Viewing all 7205 articles
Browse latest View live


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