Starting from version 17.1 we have introduced a new client-side FocusedCellChanging event. This event allows you to skip focusing and editing a cell. This example demonstrates different ways to skip or prevent editing certain cells. The main idea is to get the currently focused cell using the ASPxClientGridViewFocusedCellChangingEventArgs.cellInfo property and decide whether it is required to skip focusing or not:
This example demonstrates how to define a custom Dashboard Storage and override the LoadDashboard method that is used to load dashboards. From this method, you can update the loaded dashboard and provide the updated version to the MVCxDashboard control. In this example, a custom descendant of the DashboardFileStorage class is created. It allows defining the default parameter value and customizing the data source query to filter displayed data.
This example demonstrates how to use a dashboard Title as a file name when saving dashboards. This functionality is implemented by creating a custom dashboard storage.
This example demonstrates the use of OAuth2 authentication in a web application. Users can sign in to the application via Google, Facebook or Microsoft authentication providers.
Image may be NSFW. Clik here to view. You can try this demo "as is" to overview its capabilities, and then try the demonstrated functionality in your own XAF applications according to the instructions below.
You can remove keys corresponding to providers that you do not want to use.
Now you can run the application.
Overview of this Demo Capabilities
In the logon window, there are buttons for each provider specified in Web.config:
Image may be NSFW. Clik here to view. Standard XAF authentication with built-in username/password is also supported. When you log in via OAuth authentication, the email is used as a user name. By default, a user object is autocreated for each logon. You can disable autocreation, or specify the auto-assigned role for new users in the InitializeComponent method (see WebApplication.cs(vb)):
When CreateUserAutomatically is false, the logon is allowed if a user with the email returned by the external service exists in the application database. To grant access to a user with a specific e-mail, use the built-in Admin account, create a user object and set the UserName to this e-mail.
Image may be NSFW. Clik here to view.
If you set the EnableStandardAuthentication property to true for an auto-created user, this user will be able to login directly, with a user name and password. Note that the password is empty by default, so do not forget to specify it when enabling standard authentication.
Image may be NSFW. Clik here to view.
Each user can have several associated email addresses. To add or remove email addresses, use the OAuth Authorization Emails list in the user's Detail View.
Image may be NSFW. Clik here to view. How to Implement the Demonstrated Functionality in your XAF Application
1. In your solution, open Package Manager Console. 1.1. Choose the YourSolutionName.Web project in the Default project combo box, and execute the following commands to add Owin packages: Install-Package Microsoft.Owin -Version 3.1.0 Install-Package Microsoft.Owin.Security -Version 3.1.0 Install-Package Microsoft.Owin.Security.Cookies -Version 3.1.0 Install-Package Microsoft.Owin.Host.SystemWeb -Version 3.1.0 Install-Package Microsoft.Owin.Security.Google -Version 3.1.0 Install-Package Microsoft.Owin.Security.Facebook -Version 3.1.0 Install-Package Microsoft.Owin.Security.MicrosoftAccount -Version 3.1.0 1.2. Switch to the YourSolutionName.Module.Web project and install these two packages: Install-Package Microsoft.Owin -Version 3.1.0 Install-Package Microsoft.Owin.Host.SystemWeb -Version 3.1.0
2. Open the Web.config file and specify your own client IDs and client secrets for each provider you are going to use. Refer to the AuthenticationOwin.Web\Web.config file in the demo solution to see the example. Then, set the authentication mode to "None" and comment or remove settings related to the default XAF authentication:
3. Copy the following files from the demo solution to the corresponding locations within your solution: - AuthenticationOwin.Module\AuthenticationStandartWithOAuth.cs(vb) - AuthenticationOwin.Module\IAuthenticationOAuthUser.cs(vb) - AuthenticationOwin.Module.Web\Controllers\LogonAuthController.cs(vb) - AuthenticationOwin.Module.Web\Security\CustomSecurityStrategyComplex.cs(vb) - AuthenticationOwin.Module.Web\Controllers\LogonAuthController.cs(vb) - AuthenticationOwin.Module.Web\Images\Facebook.svg - AuthenticationOwin.Module.Web\Images\Google.svg - AuthenticationOwin.Module.Web\Images\Microsoft.png - AuthenticationOwin.Web\Startup.cs(vb) - AuthenticationOwin.Web\LogonTemplateContent1.ascx - AuthenticationOwin.Web\LogonTemplateContent1.ascx.cs(vb) - AuthenticationOwin.Web\LogonTemplateContent1.ascx.designer.cs(vb) Include the copied files to your solution (Add | Existing Item...). Update the namespace names in the copied code files to match namespaces you use in your solution. For image files, set the Build Action property to Embedded Resource. 4. Edit the YourSolutionName.Module\Module.cs file. In the overridden Setup method, handle the XafApplication.CreateCustomLogonWindowControllers event and add the LogonAuthController to the e.Controllers collection passed to this event. Refer to the AuthenticationOwin.Module.Web\Module.cs(vb) file to see an example.
5. Edit the YourSolutionName.Web\WebApplication.cs(vb) code and register this custom security strategy:
Me.securityStrategyComplex1 = New AuthenticationOwin.Module.Web.Security.CustomSecurityStrategyComplex()
6. Implement the IAuthenticationOAuthUser interface in your custom user class. You can see an example in the AuthenticationOwin.Module\BusinessObjects\OAuthUser.cs file. If you use the built-in user, you can copy the OAuthUser class to your project from the demo and set the SecurityStrategy.UserType property to OAuthUser in the Application Designer.
7. Change the code that creates your predefined users in YourSolutionName.Module\DatabaseUpdate\Updater.cs. Set EnableStandardAuthentication to true for users who can login with standard authentication (username and password). See the example in the AuthenticationOwin.Module\DatabaseUpdate\Updater.cs file.
8. Register the LogonTemplateContent1.ascx template in the YourSolutionName.Web\Global.asax.cs file:
9. Copy the LoginWith* actions customizations and the AuthenticationStandardLogonParameters_DetailView layout settings from the AuthenticationOwin.Module.Web\Model.xafml file to the same file in the YourSolutionName.Web project. If you have no model customizations in Model.xafml, you can just overwrite it with the file from demo. Ensure that the IsPostBackRequired property of each LoginWith* action is set to true.
Added By: Scott Gross at: 7/14/2017 8:43:09 AM Will this work with XAF Mobile as well?Added By: Konstantin B (DevExpress) at: 7/16/2017 11:07:04 PM We haven't yet tested this approach with XAF Mobile. However, we will consider including the mobile app project to this demo. I've created a separate ticket on your behalf (T536304: OAuth2 authentication in XAF Mobile). It has been placed in our processing queue and will be answered shortly.Added By: Rik Pronk at: 8/1/2017 6:41:49 AM In the sample project, I noticed some errors in the web.config file. Below 'For applications with a security system' the <Authentication> tag is used, but that's supposed to be the <authorization> tag instead.Added By: Konstantin B (DevExpress) at: 8/1/2017 8:49:03 AM Hello Rik,
Your comment is correct, we have updated this demo. Thanks! Added By: Martin Svärd at: 8/31/2017 3:40:34 AM Hi Konstantin,
I am not able to try this example, even though I register it with Microsoft. Am I missing something? And will this work with Microsoft Azure as well, or is it only Microsofts non O365 accounts? Added By: Dennis (DevExpress Support) at: 8/31/2017 3:55:20 AM @Martin: Thanks for your interest. I've created a separate ticket on your behalf (T550911: Difficulties when running the T535280 example (OAuth2 authentication)). It has been placed in our processing queue and will be answered shortly.Added By: Genesis Supsup 1 at: 10/23/2017 8:56:59 PM Is it possible to implement this in XAF using Windows Forms?Added By: Dennis (DevExpress Support) at: 10/24/2017 12:02:24 AM @Genesis Supsup: We will answer you in the XAF - OAuth2 Authentication for WinForms ticket. Thanks.Added By: Vince G at: 1/21/2018 11:02:19 AM For Google Authentication you will need to enable the Google+ API otherwise the google authentication won't work, that took me a while to debug.
Added By: Nikolai (DevExpress Support) at: 10/6/2015 12:35:29 AM Hi Matthias,
Please post your comments regarding this issue in the Accessing data source in dxDataGrid for updating Id from ControllerAction ticket.Added By: Milind Wadge 1 at: 11/22/2017 6:32:42 AM In this example, you have created queryhelper class which is specific to category object. Can we generate a single generic queryhelper class which can be used in any object controller?Added By: Nikolai (DevExpress Support) at: 11/22/2017 8:04:12 AM Hi Milind,
This example demonstrates how to add a check column to allow web-style multiple row selection. End-users can select/deselect rows, group rows or select/deselect all rows by clicking the column header. Changing a check box value does not initiate row editing.
Image may be NSFW. Clik here to view.
All code related to selection resides in the GridCheckMarksSelection helper class. So, to implement this functionality in your application, you can simply add this class to your project and then simply create a new GridCheckMarksSelection instance. Please note if you use the AppearanceEvenRowand AppearanceOddRowstyles, by default they have a higher priority than the RowStyleevent used for the selection in this example. To avoid drawing incorrect selected rows, enable the e.HighPriority option.
The GridCheckMarksSelection class also provides different ~Select methods which allow selecting data and group rows. To obtain selected rows, you can use the SelectedCount property and GetSelectedRow method.
Question Comments
Added By: Marc Roussel at: 10/11/2012 5:59:00 AM
Hmmm how do I use this class ?
Added By: You Logic at: 10/16/2012 4:16:54 AM
When I select a row via code, the check box is not checked. How can I do this!?
Added By: Piotr Christ at: 2/8/2013 4:13:11 AM
I had the same problem as You Logic ! How select row (with checkbox) from code ?
Added By: (no info) at: 11/25/2013 2:23:24 PM
While this is a very nice implementation there is a problem with the code. Because you have defined selection *in the CheckMarkSelection.cs" as an ArrayList it is next to impossible to get at any values contained within each of the actual selected rows from the grid. Let's say one needs to obtain two of the values within the row...one is a string and one is an integer...how do you get the values out? There are no extension methods associated with "selection" that would allow you to enumerate the data lets say using linq or even simply doing somethin like: DataRowView theRow = (DataRowView)this.selection.GetSelectedRow(i); What happens is there is a cast error that occurs due to the generic types within the ArrayList. Granted this is necessary as we have an unknown group of column objects and values. There needs to be a built in method to access the individual values in the selected rows from "selection". I have tried 12 different methods to extract them and still a Cast error occurs.
Added By: Dave Smith 6 at: 3/4/2016 2:15:24 AM After implementing this class the column does not show, not sure what I'm doing wrong.
In the constructor of my form I call new GridCheckMarksSelection(gridViewSearchInventory);
and then in the form load i bind to my grid Added By: Sasha (DevExpress Support) at: 3/4/2016 6:20:43 AM
Added By: Jacobo Amselem at: 4/14/2016 3:35:49 AM Hello How can I modify View_Click() to invert group row selection when clicking the group checkbox ONLY? Current implementation inverts selection when clicking anywhere in the group row.
Thank you Added By: Alisher (DevExpress Support) at: 4/14/2016 5:05:29 AM
Added By: Jacobo Amselem at: 4/22/2016 5:08:26 AM Hello again, How could I modify this sample so the check column is the very first column when AlignGroup SummaryInGroupRow = True?
Thank you Added By: Alisher (DevExpress Support) at: 4/25/2016 5:18:54 AM
Hi Jacobo,
The AlignGroupSummaryInGroupRow option is available starting with version 15.2 of our components. Therefore I think that you are using the latest version of our products in your project. However, the functionality implemented in this example can be used out of the box in the mentioned version. Set the GridView's OptionsSelection.MultiSelect property to True and the OptionsSelection.MultiSelectMode property to CheckBoxRowSelect to enable it. Would you please clarify why you are still using this example to achieve this functionality?
Added By: Jacobo Amselem at: 4/25/2016 5:42:49 AM Hi Alisher Yes I'm in the latest version of your components, and I'm aware of the CheckboxRowSelect option. However my original issue is the one described in : https://www.devexpress.com/Support/Center/Question/Details/T294110 (selection checkboxes are cleared when the grid is filtered). The solution to that issue sug gests to use the sample shown in this page to achieve checkbox column+filtering persistence so here I am.
My issue now is that when enabling AlignGroupSummaryInGroupRow the checkbox is shown after the grouped columns and I'd like to show it before. I did read the issue: https://www.devexpress.com/support/center/Question/Details/T365937 but it still unclear to me how can I proceed. Can you give some guidance? thank you
Added By: Alisher (DevExpress Support) at: 4/26/2016 5:40:29 AM
Hi Jacobo,
Thank you for the clarification.
At present setting the AlignGroupSummaryInGroupRow property forces the Grid to display fixed columns after grouped columns. I don't see an easy way to overcome this behavior. I have created a separate ticket (GridControl - Setting the AlignGroupSummaryInGroupRow forces the Grid to display fixed columns after grouped columns) and passed it to our developers. We will examine the possibility of placing fixed columns before grouped columns. Please add that ticket to your Favorites to be notified of our progress.
If you are using an earlier version of DevExpress controls, refer to the Multiple selection using checkbox (web style)example which demonstrates a method to manually create a check column for row selection.
Question Comments
Added By: Marco Villasesr at: 2/2/2014 8:31:14 AM
Could you please attach a sample Project, please? thank you!!
Added By: david ola at: 12/17/2015 5:18:30 AM
How do you respond to the selection change event? I needed to populate another grid based on the number of rows selected in my gridcontrol. Everything works well until no rows were selected. At that time, the SelectionChange event did not work. The other grid should be cleared when selectionCount become zero in my original gridcontrol, but it still displays the contents as if SelectionCount =1. Is that a bug?
Before I suggest a solution, I need to know which approach you use. Do you utilize the GridCheckMarksSelection helper class or the CheckBoxRowSelect select mode?
I look forward to hearing from you.
Added By: Zvi Goldenberg at: 8/22/2016 3:51:22 AM Hello. I need this functionality per column not per gridView. Is it supported? Thanks Added By: Dimitros (DevExpress Support) at: 8/22/2016 4:04:37 AM
The following example demonstrates how to check the spelling of the GridControl active cell's content. To determine the moment when the grid cell is activated, handle the GridViewBase.ShownEditor event. Call the SpellChecker.Check(Control) method to check the active editor for spelling mistakes.
This example demonstrates how to use the Rich Edit Document Server API to programmatically manage rich edit documents, without the need for Microsoft Word to be installed.
The application includes the RichEditControl used to display and edit the code. The code modifies the rich document created or loaded by the RichEditDocumentServer instance. To see the results, open the document in Microsoft Word by clicking the button.
You can modify the code and watch the result. If an error occurs during compilation or execution, the backcolor of the code window changes.
This sample introduces API properties and methods used to perform the following operations:
- Create, load, save and print documents; - Insert text to the document range or paragraph; - Change paragraph or character formatting; - Create and apply new character, paragraph or linked style; - Create bulleted or numbered lists; - Insert and resize inline pictures; - Insert and modify floating pictures or text boxes; - Create, fill, colorize tables, merge or split table cells; - Change document page layout - create columns, add line numbering, change page layout settings; - Insert bookmarks or hyperlinks; - Create, edit and delete comments; - Set document properties; - Modify page headers; - Insert and modify fields.
For more information, review the Examples section in the documentation.
To use this example in production code, the Universal Subscription or an additional Document Server Subscription is not required.
These controls require the DevExpress.AspNetCore.Reporting NuGet and xtrareportsjs Bower packages. To integrate these controls into an application, register the required services in the Startup class, reference the necessary client resources and use the ReportDesigner or WebDocumentViewer wrapper.
This example uses an Entity Framework data source as well as an SQL data source.
Before running this example, do the following: 1. To download all the required client resources for deploying the control, navigate to the application's root folder, open the console, and run the following command: bower install
2. In Visual Studio, right-click the solution and select Manage NuGet Packages for Solution. In the invoked window, switch to the Updates page, enable the Include prerelease check box (for the DevExpress.AspNetCore.Reporting package) and update the required packages. If some issues arise during updating, uninstall these packages and install them from scratch: DevExpress.Reporting.Core for the Reports library and DevExpress.AspNetCore.Reporting for the ASP.NET Core application.
LayoutGroup/LayoutControl doesn't have the built-in ItemsSource property. In this example, we demonstrated how to provide this functionality using a custom behavior class. This behavior generates LayoutItem controls when the associated collection is changed and adds them to the Children collection of the associated control.
Question Comments
Added By: Andrew Cope 2 at: 1/2/2018 3:46:31 AM I had to override the OnAttached() event:
Without this ArrangeChildren() was only called once and it was before AssociatedObject had been set.
Although so far it hasn't actually solved my problem anyway - the controls haven't lined up :-/ Added By: Ivan (DevExpress Support) at: 1/3/2018 1:32:12 AM
Hi Andrew, Your approaches are absolutely correct. I have updated this example to apply them and slightly changed the implementation to make it possible to attach our custom behavior to individual groups. It is now unnecessary to obtain groups by their names, and you also can populate multiple groups within your LayoutControl dynamically. As for the last issue, please check if it exists in the updated example and let me know your results.
Added By: Andrew Cope 2 at: 1/24/2018 6:43:38 AM Unfortunately there's another bug here :)
RearrangeChildren() is too indiscriminate when it responds to a .Reset event - it clears down everything as well as any items you have added. In my case I ended up with an almost empty view :) I modified my version to only remove FrameworkElements where the DataContext was set appropriately. In my case the DataContext is of type ButtonDescriptor: