Search This Blog

Tuesday, October 6, 2015

Confirm unsaved changes to avoid losing data when navigating to another web page - YOUR FEEDBACK IS NEEDED

Scenario

Imagine you are in an XAF ASP.NET app context and just edited a record in the DetailView or ListView directly (e.g., linked or unlinked related details, typed something in the text box, changed drop downs, etc.) and then accidentally clicked a navigation item or some other link within the app...If the Save Action was not explicitly executed before that accidental action took place, there is a risk of losing your recent edits...and sadly this sometimes happens. Thankfully, this is not the case for the WinForms platform, where it is already handled.

Current solutions

There are some custom-tailored solutions available in the Support Center (one, two), but they far from being ideal, to be honest.

Good news

As part of our continuous effort to improve the XAF Web UI (be sure to check it), the new v15.2 (should be out around December, as always) will contain a built-in solution for the aforementioned problem. 

More good news

Friday, October 2, 2015

Avoiding repetitive customizations for Views of the same type or subclasses via the Model Editor - YOUR FEEDBACK IS NEEDED

Prerequisites

Imagine you have the following data model classes:

class Party {...}

class Person : Party {...}
class Organization: Party {...}



XAF automatically generated several default root and nested Views for them in the Application Model. You can also create custom Views via the Model Editor on your own. For instance, you might end up with the following list under the Views node:


    Party_ListView
    Person_ListView1
    Person_ListViewN
    Organization_ListView1
    Organization_ListViewN



Scenario


Imagine your first goal is to customize the appearance of the ListView for the base class - Party_ListView according to your client needs.To accomplish this, you locate the Party_ListView node in the Model Editor and make various customizations to its columns. In particular, 1. edit captions for the Photo, Address1, Address2 columns; moved the Photo column after the Address1 and Address2 ones; 2. made changes to the ListView node properties such as set IsGroupPanelVisible, AllowEdit and other options in the property grid.


What if your second goal is to have a similar appearance for other ListViews where Party records are shown, e.g., Person_ListView, Organization_ListView1, Party_LookupListView or even Company_Persons_ListView (see the poll questions in the end)?


Thursday, September 17, 2015

How to enable the Conditional Formatting feature of the WinForms GridControl in the XAF GridListEditor and preserve ListView formatting settings between runs?

In short, this feature allows your end-user to sort or group the data inside the grid AND to visualize selected cells, rows with data bars, icons and predefined or custom appearance schemes. Refer to the following XtraGrid documentation for more information on this feature: 



In general, accomplishing this task in an XAF app consists of several independent parts:
2. Integrating this solution in the GridListEditor using a ViewController  as described in the Access Grid Control Properties  help topic.
3. Serializing the grid's formatting rules information, taking into account the fact that it uses a different mechanism for storing settings, which is based on the Application Model. In XAF, it is best to extend the ListView node with a string property that will hold a serialization representation of formatting rules. Refer to the How to: Extend the Application Model  article for more details.

Wednesday, September 9, 2015

How to reset View customizations made by end-users (UPDATE)

I invite you to test an updated version of the previous E1897 solution (it is now marked as obsolete), which we are planning to include in v15.2 by default. The new solution supports both WinForms and ASP.NET apps and also works for both the root and nested Views (e.g., the ones embedded into ListPropertyEditor and DetailPropertyEditor):


Tuesday, August 25, 2015

Getting ready the ConditionalAppearance module infrastructure for custom options of the extended AppearanceAttribute (e.g., tooltip)

First of all, this piece of information is quite advanced, so be sure you are well-aware of the module's basic functions and main extensibility and customization points, at least through AppearanceController. If not, check out the related online documentation before reading further. 

Customer scenario

Would it be possible to add in the conditional appearance module the possibility to show a tooltip in the cell in listView when the 
condition is satisfied? (you get different color based on criteria and when you move to the cell a tooltip is shown telling you why the color is different ), example:

[C#]
[Appearance("CategoryColoredInListView", AppearanceItemType = "ViewItem", TargetItems = "Category", Criteria = "Category = 'Seafood'", Context = "ListView",FontColor = "Blue", Priority = 1, ToolTip="the tooltiptext!!!!")]

Monday, August 24, 2015

A more straightforward and convenient way to query data using LINQ with ObjectSpace

First of all, it is important to note that the capability to query data using LINQ has been available for a long time in the current version of XAF (or better said, in the underlying Entity Framework and XPO ORM libraries). So, this improvement in v15.2 is all about improving developer usability by exposing a helper method for the IObjectSpace interface representing one of the main XAF entities (learn more...). 

As noted in the corresponding SC ticket (from here you can also learn on the current solution):

The IObjectSpace interface now declares the following method:

[C#]IQueryable<T> GetObjectsQuery<T>(Boolean inTransaction = false);
This method is implemented in the XPObjectSpace, EFObjectSpace and NonPersistentObjectSpace classes. 
The inTransaction parameter has effect in XPO only and enables the mode in which querying a data store for objects includes all in-memory changes into query results.
In the NonPersistentObjectSpace, the GetObjectsQuery method casts the collection of objects created in the ObjectsGetting event to IQueryable and returns the result.

For XPObjectSpace, this method just returns a new XPQuery<T> from the underlying Session, while for the EFObjectSpace, the GetObjectsQuery method returns a new instance of ObjectQuery<T> with the help of the associated DbContext.

Here are a few usage examples from our unit tests (using the method-based query syntax):
EF:
IQueryable<Product> objectsQuery = objectSpaceB.GetObjectsQuery<Product>().Where(p => (p.Supplier.ID == supplier_A.ID));
Assert.AreEqual(5, objectsQuery.Count());
Assert.AreEqual(3, objectsQuery.Where(p => (p.Name == "A")).Count());
Assert.AreEqual(2, objectsQuery.Where(p => (p.Name == "B")).Count());

XPO:
IQueryable<TestObject> query = objectSpaceB.GetObjectsQuery<TestObject>();
Assert.AreEqual(5, query.Count());
Assert.AreEqual(3, query.Where(t => t.StringProperty == "A").Count());
Assert.AreEqual(2, query.Where(t => t.StringProperty == "B").Count());

I hope you will appreciate this minor improvement and it will save you from polluting your code by the casts to the XPObjectSpace/EFObjectSpace types to access the underlying ORM data context LINQ features.

How to place an Action in a different location programmatically

I think that many people know that they can control this visually by drag&drop under the ActionDesign | ActionToContainerMapping node in the Model Editor, but just a few know of the best code solution. A good scenario when it is necessary to handle this requirement in code is described by our customer in this Support Center ticket (more real user scenarios can be found here).

After receiving enough requests for this, we decided to put a full example solution in our docs. It is based on handling a single CustomizeContainerActions event of the built-in ActionControlsSiteController (or FillActionContainersController class, if your form template does not support the IActionControlsSite  interface).

Do not miss this new online documentation and hopefully, it will help you spend less effort on accomplishing your advanced business requirements in our framework.