Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all 7205 articles
Browse latest View live

dxDataGrid - How to utilize CRUD operations using the context menu

$
0
0
This example demonstrates how to implement a context menu for editing, adding and deleting rows of dxDataGrid.
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.

DataGrid - How to use DropDownBox as a column editor in edit mode

$
0
0

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

Question Comments

Added By: Johseffer Wellynton Chepli at: 11/20/2017 2:31:06 AM    Can u send me this approach on angular, with this column directly in the template without jquery?
Added By: Artem (DevExpress Support) at: 11/20/2017 3:15:22 AM    

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.

MVC DataGrid - How to use DropDownBox as a column editor in edit mode

How to insert a CheckBox into a RichEditControl document

$
0
0

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.

How to control the visibility of element properties in End-User Report Designer

$
0
0

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.
Question Comments

Added By: Hughes Torres at: 6/14/2013 9:16:24 AM    

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

How to use custom SQL queries as a data source in XPO via Common Table Expressions (CTE)

WPF Report Designer - How to hide properties of reports and their elements

$
0
0

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.

How to: Bind to an OLAP Cube Using the ADOMD.NET Data Provider


How to: Bind to an OLAP Cube Using the ADOMD.NET Data Provider

Implementing context menus for TreeList nodes

$
0
0

This example demonstrates how to implement a popup menu for XtraTreeList's nodes

Question Comments

Added By: Ralph Stadie at: 1/30/2018 1:02:30 AM    I think you need to be able to see the Form1.cs.designer class as well to fully illustrate this example.

ASP.NET Core Dashboard - How to implement the Save As and Delete functionality by creating custom extensions

MVC Dashboard - How to implement the Save As and Delete functionality by creating custom extensions

$
0
0

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

Web Dashboard - How to implement the Save As and Delete functionality by creating custom extensions

$
0
0
This example demonstrates how to add the "Save As" and "Delete" menu items to the Web Dashboard control.
This functionality is implemented by creating custom extensions with the approach from T466716: Web Dashboard - How to work with extensions.
To learn more about extensions, see Working with Extensions.

See also:
T504201: MVC 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

WPF Report Designer - How to register a custom page in the Report Wizard

$
0
0

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

WPF Report Designer - How to customize the list of data providers in the Data Source Wizard

$
0
0

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


How to change connection to the database at runtime

$
0
0

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.

Question Comments

Added By: Mario Blatarić at: 11/5/2012 11:23:09 AM    

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).

Added By: Mario Blatarić at: 3/14/2013 9:51:50 AM    

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?

Added By: Dennis (DevExpress Support) at: 3/28/2013 4:52:33 AM    

@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.

Added By: Mario Blatarić at: 3/28/2013 6:17:17 AM    

Thanks Dennis. I understand now how this works.

Added By: lekan odejimi at: 1/29/2014 1:28:06 AM    

Hi 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 AM    

Hi,

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 AM    

Hi 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 PM    

Hi 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

Added By: Dennis (DevExpress Support) at: 12/22/2015 1:26:06 AM    

@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.

Added By: Robert Sanford at: 12/22/2015 3:43:08 PM    

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'm using SQL Server. Any advice ? Added By: Dennis (DevExpress Support) at: 1/16/2017 6:21:49 AM    @Alexandre BOYER:

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,


Is there a way to do something similar in the mobile framework?


Kind regards,


Paul
Added By: Dennis (DevExpress Support) at: 1/30/2018 6:56:45 AM    

@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.

How to create a text markup annotation and specify its properties

How to find text using a keyboard shortcut

$
0
0
This example shows how to execute the Find Next action by pressing the F3 shortcut after an end-user specified search options in the Find Text dialog. 

To do this, handle the PdfViewer.KeyDown event. If the F3 key is pressed, call the overloaded PDFViewer.FindText  method and pass the text to search and search parameters obtained from the Find Text dialog to this method.  

The text search settings (e.g, search text, whole words, case sensitive) applied by an end-user in the Find Text dialog can be accessed using the PdfViewer.FindDialogOptions property.

Outlook Inspired App (EF data model only)

How to: show a ToolTip containing information about the document layout element located under the cursor position

$
0
0
This example demonstrates how to use the HitTestManager class to obtain document layout elements located under the specific point and show this information in the ToolTip.
Use the HitTestManager.HitTest method to get the RichEditHitTestResult object providing information about a specific document element which is located under the test point. Retrieve the layout element using the RichEditHitTestResult.LayoutElement property or obtain the hit information about the element positioned next to the current hit element using the RichEditHitTestResult.Next property. After that, display the required information about the document layout element in the ToolTip.
Viewing all 7205 articles
Browse latest View live


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