Giter VIP home page Giter VIP logo

xaf-save-and-share-custom-view-settings's Introduction

XAF - How to Save and Share Custom View Settings

In XAF applications, view settings are stored for each user individually. When a user changes a view (for example, adds a column to a list view or groups a detail view's items), these settings are saved in the user's model differences and applied to this view the next time this view is displayed.
The built-in View Variants Module allows you to create multiple predefined view settings in the Model Editor or in code. It also allows an end user to select a view variant at runtime.

This example implements functionality required to save customized view settings as new view variants at runtime, share them between users, and allow any user who has appropriate permissions to select a variant and apply its settings to a view.

NOTE: The approach demonstrated in this example may be inappropriate or overly complex in certain use cases. Thus, we cannot guarantee that it will work in all possible use case scenarios. Do not hesitate to modify it so it handles your business needs.

Implementation Details

The example application uses a persistent class to store view settings in the database and a view controller with actions used to manage these settings (create, apply, and delete). Each user can create his/her own view variants. Each view variant can be optionally marked as shared, so that other users can see this variant in the UI and apply it to their views.

Add a Persistent Class to Store View Settings

First, create the SettingsStore business class used to store the View settings. This class should have the following properties:

  1. Xml - A string where serialized view settings are stored.

  2. Name - The name of the view variant.

  3. OwnerId - An identifier of the user who created this variant.

  4. IsShared - Specifies whether this variant is shared with other users.

  5. ViewId - An identifier of the view for which this variant is created.

Add a Custom View Controller

Create a ViewController that defines the following behavior:

  1. The shared model settings are available to all users but cannot be edited by them.

  2. Each user has his/her own default settings saved in the user's model and used when no variant is used.

  3. The SaveAsNewViewVariant action creates a new view variant based on customizations made to a view. The created variant is assigned as the current variant. If this is the first variant created for the view, the action additionally creates a variant that stores the default settings (named "Default").

  4. The SelectViewVariant action allows a user to select a view variant from a combo box and makes the selected variant current. This action is available when at least one variant exists. When a user changes the current view variant, all customizations previously made to the view are lost, except for changes made to the "Default" view variant.

  5. The UpdateCurrentViewVariant action saves customizations to the currently selected view variant.

  6. The DeleteViewVariant action deletes the current view variant. After deletion, the "Default" view variant becomes current and its settings are applied.

  7. The UpdateDefaultViewVariant action saves customizations made to the current view in the "Default" variant.

In the example application, the actions that ViewVariantsController implements look as follows:

View Controller Actions in UI

You can extend and adjust the demonstrated functionality based on your requirements. For example, you can:

  • Use the Security System facilities to prohibit certain users from deleting view variants.

  • Store the current variant in the model (see the Change the Application Model topic in our documentation) or in the user object's property and apply it when the corresponding view is opened.

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

xaf-save-and-share-custom-view-settings's People

Contributors

87alex avatar andreykozhevnikov avatar devexpressexamplebot avatar dxmi avatar eugeniyburmistrov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.