Question Comments
Added By: Wilfredo Gutierrez at: 1/25/2018 5:19:09 AM Could you please update this example to ASP.NET CORE 2 MVC?
Thank you.
This example illustrates how to use dxDropDownBox with an embedded dxDataGrid for editing data. Run the example and check the State column to see this approach in action.
Click the "Show Implementation Details" link to see step-by-step instructions.
See also
DataGrid - How to use DropDownBox as a column editor in edit mode
Hello Johseffer,
To process your inquiry more efficiently, I've created a separate ticket on your behalf (T578517: dxDataGrid - How to use dxDropDownBox as a column editor in edit mode in Angular). Please refer to it for further correspondence.
This example illustrates how to define dxDropDownBox with an embedded dxDataGrid for editing data in MVC via an EditCellTemplate. Run the example and check the State column to see this approach in action.
For a client-side solution, please refer to the dxDataGrid - How to use dxDropDownBox as a column editor in edit mode example.
Click the "Show Implementation Details" link to see step-by-step instructions.
This example demonstrates how to imitate a CheckBox control in a document by inserting Unicode characters and allow changing the CheckBox state on a mouse click.
Use the HitTestManager.HitTest method to get the RichEditHitTestResult object providing information about a specific document element which is located under the mouse cursor. Retrieve the layout element using the RichEditHitTestResult.LayoutElement property, check whether this element is a CheckBox character, and change its checked state by replacing the clicked character with another one.
This example illustrates how to hide properties of a report, its bands and controls from the End-User Report Designer's Properties panel by handling the XtraReport.FilterComponentProperties event.
Starting with v17.2, reports use binding expressions, which you can specify in the Properties panel's Expression tab. To hide properties from this tab, use the ExpressionBindingDescriptor.HidePropertyDescriptions method.When I download the full project of this this sample(runner) it and opens in studio2010 and no project is loaded. On get (WindowsFormsApplication13(incompatible)) in the solution explore. I am downloading the VB but the C download is the same.
Thanks Hughes
See article How to use custom SQL queries as a data source in XPO via Common Table Expressions (CTE)
This example illustrates how to hide properties of a report, its bands and controls from the End-User Report Designer's Properties panel by handling the XtraReport.FilterComponentProperties event.
Starting with v17.2, reports use binding expressions, which you can specify in the Properties panel's Expression tab. To hide properties from this tab, use the ExpressionBindingDescriptor.HidePropertyDescriptions method.
The following example demonstrates how to bind PivotGridControl to an OLAP cube via the ADOMD.NET data provider.
Update: starting with version 12.1, it is enough to use the OlapDataProvider property to specify the required data provider.
See Also:
KA18860: OLAP - The user credentials (Name, Password) specified in the connection string are ignored and the connection is established from the name of the current application user
The following example demonstrates how to bind PivotGridControl to an OLAP cube via the ADOMD.NET data provider.
See Also:
KA18860: OLAP - The user credentials (Name, Password) specified in the connection string are ignored and the connection is established from the name of the current application user
This example demonstrates how to implement a popup menu for XtraTreeList's nodes
This example demonstrates how to add the "Save As" and "Delete" options to the MVC Dashboard control.
It requires only a few changes to utilize the solution described in the T466716: Web Dashboard - How to work with extensions article in MVC:
1. Use the SetDashboardStorage method to define the default storage:
[C#]protectedvoidApplication_Start(){//...DashboardConfigurator.Default.SetDashboardStorage(newDashboardFileStorage(Server.MapPath("~/App_Data/Dashboards")));//...}
2. Handle the client-side BeforeRender event using the DashboardExtensionSettings.ClientSideEvents property:
[C#]@Html.DevExpress().Dashboard(settings=>{settings.Name="Dashboard";settings.ClientSideEvents.BeforeRender="onBeforeRender";}).GetHtml()
3. Define a controller action that should be used to delete dashboards:
[C#]publicActionResultDeleteDashboard(stringDashboardID){CustomDashboardFileStoragenewDashboardStorage=newCustomDashboardFileStorage(@"~/App_Data/Dashboards");newDashboardStorage.DeleteDashboard(DashboardID);returnnewEmptyResult();}
4. Customize the DeleteDashboardExtension.deleteDashboard function to call the server-side DeleteDashboard action using AJAX:
[JavaScript]this.deleteDashboard = function(){if(_this.isExtensionAvailable()){if(confirm("Delete this Dashboard?")){var dashboardid = _this._control.dashboardContainer().id;var param = JSON.stringify({ DashboardID: dashboardid, ExtensionName: _this.name }); _this._toolbox.menuVisible(false); $.ajax({ url: 'Home/DeleteDashboard', data: { DashboardID: dashboardid }, type: 'POST',}).success(function(){ _this._control.close();});}}}
See also:
T466761: Web Dashboard - How to implement the Save As and Delete functionality by creating custom extensions
T601084: ASP.NET Core Dashboard - How to implement the Save As and Delete functionality by creating custom extensions
This example demonstrates how to extend the End-User Report Designer's Report Wizard with a custom page that allows you to edit the report page settings. This page is displayed after selecting the report type (for empty and data-bound reports).
To accomplish this task, perform the following steps:
1. Create a custom page Presenter by inheriting from the WizardPageBase<TView, TModel> class (from the DevExpress.Data.WizardFramework namespace) . Implement the logic to pass data between a Model and View, specify the next wizard page type and define which page buttons should be available.
2. Declare an interface identifying the wizard page View.
3. Create the page ViewModel by inheriting from the WizardPageBase class (from the DevExpress.Xpf.DataAccess.DataSourceWizard namespace) and implementing the interface declared above. This ViewModel processes data for displaying it in the user interface.
4. Write a XAML template with the ViewModel type referenced by a Key to define the page's visual appearance and layout. The specified Key is used to automatically locate the corresponding template.
5. Create an XtraReportModel class descendant, add custom fields storing the report page settings and override the Equals method to take into account the added fields.
6. Override the existing ChooseReportTypePage Presenter to set the next page to your custom one.
6. Implement the IWizardCustomizationService interface, which provides four methods for wizard customization. In this implementation, register the previously created Presenters, ViewModel and Model as well as write the logic for building a report.
See Also
WPF Report Designer - How to customize the list of data providers in the Data Source Wizard
This example illustrates how to customize the list of data providers displayed on the Specify a Connection String page of the Data Source wizard and Report wizard (e.g., to leave only the Microsoft SQL Server option), as well as make the wizard always start with this page.
To do this, assign an object implementing the DevExpress.Xpf.Reports.UserDesigner.IWizardCustomizationService interface to the ReportDesigner.ServicesRegistry property.
See Also
WPF Report Designer - How to register a custom page in the Report Wizard
Scenario
This example illustrates how to connect your application to another database after the application is already started. This can be required for a multi-tenant application where you need to associate a user or company with their own database of the same structure. You can choose a required database and user during the login procedure and also later in the application UI by using the specialized SingleChoiceAction (available for Admin only). The created databases will have the same structure, but can have a different predefined data set.
Steps to implement
1. Using the XAF Solution Wizard, create a new XAF app named RuntimeDbChooser and that uses XPO for data access and the Security module with the Authentication = Standard and UI-level mode options.
2. Copy code that creates predefined security users for each database from the RuntimeDbChooser.Module\DatabaseUpdate\Updater.xx file into YourSolutionName.Module/DatabaseUpdate/Updater.xx;
3. Copy and include the RuntimeDbChooser.Module\BusinessObjects\CustomLogonParameters.xx file into the YourSolutionName.Module/BusinessObjects folder; *
4. Copy and include the RuntimeDbChooser.Module.Web\WebChangeDatabaseController.xx and RuntimeDbChooser.Module.Web\WebCustomAuthentication.xx files into the YourSolutionName.Module.Web project;
5. Copy and include the RuntimeDbChooser.Module.Win\WinChangeDatabaseController.xx and RuntimeDbChooser.Module.Win\WinCustomAuthentication.xx files into the YourSolutionName.Module.Win project;
6. Copy and include the RuntimeDbChooser.Wxx\WxxApplicationEx.xx files into the YourSolutionName.Wxx project;
7. Replace the line that instantiates your WinApplication descendant in the YourSolutionName.Win/Program.xx file with the CreateApplication method call as shown in the RuntimeDbChooser.Win/Program.xx file.
8. In the Application Designer invoked for the YourSolutionName.Web/WebApplication.xx file, select the Authentication Standard component and set its LogonParametersType property to RuntimeDbChooser.Module.BusinessObjects.CustomLogonParametersForStandardAuthentication
You can learn more on the approaches used in points 2-4 from the eXpressApp Framework > Task-Based Help > How to: Use Custom Logon Parameters and Authentication article.
____
* In this example, the available database names are hard-coded in the MSSqlServerChangeDatabaseHelper class and supplied to the DatabaseName property editor using the PredefinedValues model option. To populate the PredefinedValues list with names that will be known only at runtime, use the approach described in these articles (Win and Web specific):
How to: Supply Predefined Values for the String Property Editor Dynamically (WinForms)
How to: Supply Predefined Values for the String Property Editor Dynamically (ASP.NET)
A custom editor described in these articles can be assigned to the DatabaseName property using the Model Editor.
Let me give you "some reasons" why this isn't such a specific scenario.
- accountant company doing accounting for several different companies (it's business requirement that data for each company is in separate database)
- building maintenance company - again - business requirements demands each building to live in separate database (because of financial data)
- document managment companies doing document management for multiple companies - again, each company must live in seperate database
- local community combined with utility company - same people do both things and want to keep things separated
If you like, I can go on. No, you can't go to this companies / communities and say "But, it's better if we put all this to one database" because they will reply "Thank you, we'll find someone who can do it with multiple databases".
The point is, there are many reason why one piece of software should be connecting to multiple databases, so it's not such a specific scenario really. It would be nice to have this functionality out of the box instead of implementing this hard to understand piece of code.
Also, since application is distributed to many different clients, it would be nice that end-user could setup application on first startup (add/create required databases with connection info).
This example doesn't work.
Go to WinChangeDatabaseController.cs and set breakpoint in changeDatabaseAction_Execute. This code never executes since created SingleChoiceAction is not visible on logon form, instead some default editor is created with PredefinedValues and it's behaviour is not modified.
Can you fix this code please?
@Mario: I have answered you in www.devexpress.com/issue=Q484359
This example worked correctly in my tests. In any event, I have just updated it to .NET Framework 4.0, just for more convenience.
Thanks Dennis. I understand now how this works.
Added By: lekan odejimi at: 1/29/2014 1:28:06 AMHi Dennis, each time i try to logon i keep on getting this error: "Make sure your user name is correct and retype the password in the correct case." What do you suggest?
Added By: Grégoire Perruchoud at: 3/20/2014 9:52:00 AMHi,
Great piece of code !
I noticed a weakness. In Web/Win controllers, preselection of correct item is done via following code :
if (Application.ConnectionString.Contains((string)item.Data))
This fails in case database name's string is contains elsewhere in ConnectionString. It also fails in case we have multiple databases with names containing each other, for example "customers" and "customers_geneva".
We should store the current database name in a static property somewhere and make a strong comparison.
Added By: Achmad Mulyadi at: 8/15/2015 12:11:19 AMHi Dennis,
From the code below,
public const string Databases = "ChangeDatabase_DB1;ChangeDatabase_DB2";
Is there anyway I can pass a dynamic attribute value? I know this attribute requires a fixed value in compile time, but I don't think it is practical to put the database name or maybe a server address in a hard coded way. For example, it would be very practical if we can read this value from the app.config file, and pass it to the ModelDefault attribute.
Added By: Dennis (DevExpress Support) at: 8/17/2015 8:12:50 AM @Achmad: Sure, please check out a possible solution at How to make example E1344 work with runtime defined databases. I hope this meets your needs.Added By: Robert Sanford at: 12/21/2015 3:36:59 PMHi Dennis,
Would it be possible to post a complete XAF solution that incorporates this logic please along with tutorial? I have a single database XAF app that now has multiple database requirement - the various sql server databases would be defined in web.config. Thanks
@Robert: Thanks for your suggestion. We will take it into account for the future.
In the meantime, would you please submit a separate ticket and describe your business requirements in greater detail? It is possible that you can use other approaches to meet them. For instance, I feel that How to connect different ORM data models to several databases within a single application can be suitable here.
Dennis, yes I will do that, thanks. Basically, I need to take an existing XAF VB.NET solution - one model, one database - and expand this to several databases, allow user to authenticate to their database based on user/account ID. Each SQL server (SQL Azure database) will be identical. Thanks
Added By: Dennis (DevExpress Support) at: 12/23/2015 1:04:34 AM @Robert: Thanks, I will answer your new Convert existing XAF solution to allow access multiple idential databases authenticated by UserID ticket.Added By: Alexandre BOYER at: 1/15/2017 1:59:47 PM Great work. But the Password is removed from the ConnectionString, so it is not possible to connect to the selected database even when i add "Persist Security Info=true"I've created a separate ticket on your behalf (T472395: E1344 implementation for a scenario when a connection string contains user and password information). It has been placed in our processing queue and will be answered shortly.
Added By: Paul van Keulen at: 1/30/2018 6:22:42 AM Hi,@Paul: We have a Knowledge Base article demonstrating how to update the ServiceUrl option after a Mobile application starts: How to change the default data service URL in XAF Mobile applications at runtime (it is implied that different services will connect to different databases). If this solution does not meet your needs, please describe us your exact use-case scenario and expected results (in a separate ticket, if possible) so that we can consider it for the future.