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

How to search for a location on a map using a custom search panel

$
0
0

This example demonstrates how to find a city on a map using the Microsoft Bing Search data service.

Note that the built-in search panel is not applicable in this example, so the BingSearchDataProvider.ShowSearchPanel property is set to false.

To find a city on the map, type it in the custom search panel and click the Go button. A search location parameter is passed to the BingSearchDataProvider.Search method, and you can see a desired location on the map. Note that there are 5 overloads for the Searchmethod, depending on your search criteria.

If you run this sample as is, you will get a warning message stating that the specified Bing Maps key is invalid. To learn about how to register a Bing Maps account and create a key for it, refer to How to: Get a Bing Maps Key tutorial.



How to calculate a route between waypoints and customize the appearance of a route path using a Microsoft Bing Route web service

$
0
0

This example demonstrates how to calculate a route between several waypoints and change the appearance of a route path by means of the Microsoft Bing Route web service.

To calculate a route between waypoints, call the BingRouteDataProvider.CalculateRoute method and pass a list of waypoints as its argument.

To customize the route path appearance, do the following:

- Handle the BingRouteDataProvider.RouteCalculated event;
- Access the route path using the RouteCalculationResult object inside the BingRouteDataProvider.RouteCalculated event handler's BingRouteCalculatedEventArgs;
- Create a MapPolylinewith calculated route points. To access the route points collection, use the BingRouteResult.RoutePath property;
- Customize the stroke and stroke width of the map polyline using the MapItem.Stroke and MapItem.StrokeWidth properties.

The map pushpins are generated automatically at each route waypoint position because the InformationDataProviderBase.GenerateLayerItemsproperty is set to true by default. Note that the pushpins' text contains an empty string.
To number route waypoints (from start to finish) in the pushpin, handle the InformationDataProviderBase.LayerItemsGeneratingevent and modify the MapPointer.Text property.

Note that if you run this sample as is, you will get a warning message saying that the specified Bing Maps key is invalid. To learn more about Bing Map keys, please refer to the How to: Get a Bing Maps Keytutorial.


How to get additional search results using the Bing Map Search service

$
0
0

This example demonstrates how to provide search for location and keywords using the BingSearchDataProvider.Search method.

In this example, the built-in Search panel is disabled (the BingSearchDataProvider.ShowSearchPanel property is set to false), because a custom panel is used instead.

To start search, specify search parameters (location and a keyword) in the custom Search panel and click the Search button. All search parameters are passed to the Search method and you can see the result in the rich text box element.

The results contain a display name, and address associated with the search location. In addition, the SearchRequestResult.AlternateSearchRegions property returns results of searching for alternate regions.

Note that if you run this sample as is, you will get a warning message saying that the specified Bing Maps key is invalid. To learn how to register a Bing Maps account and create a key for it, refer to the How to: Get a Bing Maps Keytutorial.


ASPxButton - How to disable default appearance starting with 13.2 (display only an image)

How to: Create an Action Using the ActionAttribute

How to connect the map control to a MS Bing Geocode web service

$
0
0

This example demonstrates how to provide the capability for end-users to click on a map and get detailed information about this place in the pushpin's tooltip, thanks to the Bing Geocode web service.

Note that if you run this sample as is, you will get a warning message saying that the specified Bing Maps key is invalid. To learn more about Bing Maps key, please refer to the How to: Get a Bing Maps Key tutorial.

Getting Started with the Scheduler

How to create a master-detail report bound to an ORM (Entity Framework) model in MVC applications

$
0
0

This example demonstrates how to create a master-detail report bound to Object Relational Model in ASP.NET MVC applications.

This example uses the Entity Framework ORM model to provide a report with data, but you can use any object model instead.

Bind your XtraReport to your model master class by using the approach suggested in the Providing Data to a Web Report => Design-Time Data Binding Using BindingSource help topic. After your report is bound to the master class you can easily insert a detail report band by using the context menu in the report designer, as shown below:

See also:
How to bind a report displayed in the DocumentViewer extension to the model's data


How to customize a Report Wizard for WPF

$
0
0

This example demonstrates how to customize a Report Wizard for WPF by removing its Grouping and Summaries pages.


To provide a custom report wizard, do the following:

- Create a descendant class for each page to be included in the wizard. For each custom page class, override the ReportWizardPage.GetNextPageType method to define the order in which the pages will appear in the wizard.

- Create a descendant class for ReportWizardPageFactory<ReportModel> and override its ReportWizardPageFactory.RegisterDependencies method to register the custom wizard pages.

- Create a descendant class for ReportWizardLauncherService<ReportModel> and override its ReportWizardLauncherService.CreatePageFactory method so that it returns a new instance of the previously defined custom factory.

To register a custom wizard launcher service for the Report Designer, create a new instance of the custom wizard launcher service and pass it to the ReportDesigner.Model.DesignServices.RegisterInstance<IReportWizardLauncherService> method.

dxMap - How to add draggable markers

dxMap - How to add the current location marker

$
0
0

This example describes how to use the dxMap widget with HTML5 Geolocation.

See also:
How to take advantage of map provider API features that were not implemented in the dxMap widget?
dxMap - How to add draggable markers

Example Comments

Added By: Joe Ehrenfeld at: 9/17/2013 7:29:57 AM    

I'm getting this error when I try to use the code below:
Error: Object doesn't support property or method '_initMap'

Added By: Marion (DevExpress Support) at: 9/17/2013 9:51:47 PM    

@Joe,
It seems that the dxMap is not found. Please open a new thread and post your sample.

Added By: Franco Bonacchi at: 11/19/2013 10:40:08 AM    

Please update this example for 13.2.3 (Beta)

_initMap() is no more

Added By: Marion (DevExpress Support) at: 11/20/2013 2:07:18 AM    

@Franco,
We will update this example when the official release is published.

Added By: Franco Bonacchi at: 12/4/2013 9:56:12 AM    

Is 13.2.5 the official release? I'm waiting for this to make my maps work again! Thanks.

Added By: Marion (DevExpress Support) at: 12/5/2013 4:09:12 AM    

@Franco, I have updated the example.

How to: Store Model Differences in Database

$
0
0

This example illustrates how to store user UI settings (so-called model differences) in the application database instead of the file system (in Windows Forms applications) and session (in ASP.NET appications).


By default, an XAF Windows Forms application stores user customizations of the Application Model in the Model.User.xafml file, located in the application's directory. The application's model difference storage is also file-based (Model.xafml file). These two layers are superimposed when running an application. All model-related changes made by the end-user (e.g., layout customizations) are saved to the Model.User.xafml. The potential disadvantages of this default approach are:


- The Model.xafml file is not shared (except when the application is deployed to the terminal server). So even if this file is modified by an administrator, it must be re-deployed to all users to take effect;

- Since model differences are stored in a plain XML format, anyone who has access to XAFML files can easily influence the work of the application. So, it is possible to affect a critical setting that will cause the application to stop functioning;

- Several users sharing the same copy of the application cannot have individual customizations. This can be resolved by changing the user differences file location to the user profile folder (by setting the UserModelDiffsLocation key value to the CurrentUserApplicationDataFolder in the application configuration file). However, the problem persists if users are working under the same system account.

By default, an XAF ASP.NET application stores user customizations of the Application Model in the session. The global application model difference storage is file-based (Model.xafml file located in the web application folder). These two layers are superimposed when running an application. All model-related changes (e.g., columns order and visibility in List Views, dashboard layouts, etc.) made by end-users are saved to cookies. If a user accesses the ASP.NET application via several different devices (desktop, laptop or tablet), settings are not synchronized.


Generally, you can use the default storage in most scenarios. However, the disadvantages listed above become critical if you wish to give more power to application administrators and enhance application security. This example provides a solution that eliminates all these disadvantages. The main idea is to store all model differences in the application's database. Follow the instructions below to use the database model difference storage in your XAF application.

Build the DatabaseUserSettings.dll Assembly

- Download the solution attached to this example.

- Upgrade the downloaded solution up to your currently installed version of DXperience. Use the Project Converter utility for this purpose.

- Open the converted solution in Visual Studio. Switch to the Release configuration and build the DatabaseUserSettings project (this project contains the module that we are going to use).

- Copy the DatabaseUserSettings.dll assembly to an appropriate location in your development workstation.


Add the DatabaseUserSettings Module to Your XAF Solution

- Open your XAF solution that will use the DatabaseUserSettings module.

- Add the DatabaseModelStrorage.dll reference to the platform-agnostic module project.

- Right-click the Module.cs file and choose View Code. Modify the module's constructor in the following manner.

          

[C#]
publicsealedpartialclassMySolutionModule:ModuleBase{publicMySolutionModule(){InitializeComponent();this.RequiredModuleTypes.Add(typeof(DatabaseUserSettings.DatabaseUserSettingsModule));}}

Note:Alternatively, you can add the DatabaseUserSettings in the Module Designer.But you should register the DatabaseUserSettingsModule toolbox item first (see How to: Add Items to the Toolbox).

Now you can logon using different credentials and apply different customizations for each user. For instance, you can change the active skin for each user. Different users will have different skins selected after the application is restarted. Users should have read/write access to the XPUserSettings and XPUserSettingsAspect persistent types (these types are provided by the DatabaseUserSettings module and are used to store model differences).

The Configurator Account

To manage default model settings applied to users, a special Configurator account can be used. All customizations made by Configurator in the Model Editor or directly in the UI will be stored to the shared Application Model layer. To create such an account, do the following.


- Add a Role named "Configurator" (this name is declared by the DatabaseUserSettingsModule.ConfiguratorRoleName constant).

- For the added Role, grant full access to the XPUserSettings and XPUserSettingsAspect persistent types and read access to the UserName member of the type that represent users in your application (SecuritySystemUser by default). Alternatively, you can simply mark this role as administrative (see SecuritySystemRoleBase.IsAdministrative).

- Add a User named "Configurator" (this name is declared by the DatabaseUserSettingsModule.ConfiguratorUserName constant), and associate this user with the "Configurator" role.

Refer to the Updater.cs file to see the code.

The ManageUserSettings Action

The Configurator user has access to the ManageUserSettings Action. This Action of the PopupWindowShowActiontype is provided by the ManageUserSettingsWindowController Controller implemented in the DatabaseUserSettings module. This Action is intended to import a user setting from one user to another.

See Also
Core - Provide an easy way to store administrator and user model differences in a custom store (e.g., in a database)
A reusable XAF module for storing model settings in the database (security system type insensitive!)

ImportantNotes
1.
Be aware of the following issue with this example: User settings may be duplicated/overridden under certain circumstances after merging configurator and user settings applied to the same element
2. This example solution is not yet tested in the middle-tier and SecuredObjectSpaceProvider scenario and most likely, it will have to be modified to support its specifics.
3. This example solution is not yet tested with custom fields.

Example Comments

Added By: Pawel Rymarczyk 1 at: 5/20/2012 6:35:40 AM    

Hi,

Not working with DbUpdater 11.2.

Ticket: http://www.devexpress.com/Support/Center/Question/Details/Q400938

Added By: Sandro Welter (Intelligix) at: 7/6/2012 10:14:37 AM    

Hi,

I need this example in 12.1 version. Thanks.

Added By: Robert Fuchs at: 7/11/2012 8:25:44 AM    

> Take special note that it is important to grant write permissions for
> your persistent model differences classes to the anonymous user:

AFAIR the new security system does not need an anonymous user any more?

Added By: Miles at: 7/12/2012 12:44:42 PM    

12.1 version please!

Added By: Frank (DataJunxion) at: 8/10/2012 11:00:41 PM    

12.1 version?

Added By: John Botibol at: 9/12/2012 1:09:39 AM    

Hi Guys, the Issue (Q421353) mentioned above as one to be aware of is marked as private so this is quite tricky!

Added By: Paolo Parente at: 10/31/2012 7:21:27 AM    

Hi, is there a way to download the whole solution, without select every single file?
Thanks,
Paolo

Added By: Paolo Parente at: 11/2/2012 11:13:32 AM    

Ok, i did it.
But now i've a question: i can i deploy the new Model.xafml when a new version of the application has been developed?
Thanks,
Paolo

Added By: Markus Hoevermann at: 11/5/2012 1:03:53 AM    

I have the same problem as Paolo: How to handle the case when a new softare version with another Model.xafml must be distributed? Is there a ay to do this?

Added By: Dennis (DevExpress Support) at: 11/6/2012 12:03:35 PM    

I have answered your question about deploying the new version in http://www.devexpress.com/Support/Center/Issues/ViewIssue.aspx?issueid=Q443198

Added By: Robert Fuchs at: 12/15/2012 10:38:45 AM    

http://www.devexpress.com/issue=Q421353 is still private.
Is it fixed in the 12.2 example?

Added By: Nektarios Patelis at: 12/28/2012 12:09:23 AM    

Iuse linq queries and Custom fields on model.xafml following http://www.devexpress.com/Support/Center/Example/Details/E859. I get exception on project start up: An error with number 1009 has occurred.
Error message: Error occurs while adding the 'FieldName_Linq' custom property ('System.Double' property type) to the 'MyClassName' type: 'Object reference not set to an instance of an object.'

Added By: Dennis (DevExpress Support) at: 1/29/2013 6:43:43 AM    

Guys, please refer to the public http://www.devexpress.com/issue=Q470416 ticket instead of the private Q421353 one.

Added By: Mr292 at: 1/30/2013 5:44:44 PM    

Dennis, Thanks a lot for this. I had implemented something similar before but I have now moved to your code so as to take advantage of any future changes.

I have a few questions though

1. Does the Model.xafml in the Program Folder get hit at all? It does not seem like it from the code, but wanted to be sure.
2. I had implemented a feature where on exit, the configurator would be prompted to store changes. I have modified this to do the same but in my implementation, the user was being prompted twice. This I have noticed is an issue with a lot of functions in XAF but is usually solvable easily. In this instance, what should I check for to disable the consecutive prompt?
3. Lastly, Just so some users are aware I was having issues saving Chart/Pivot Settings as XML in MySQL if I use latin1 in innodb. Not your fault but I had implemented a BLOB save instead to get over that.

Added By: Vitaly Alekseev (Sibintek) at: 3/26/2013 10:44:39 PM    

How can I logon by Configurator user, if domain authentication used?

Added By: Nate Laff at: 4/12/2013 8:09:31 AM    

Implemented this yesterday after using the example of this from a long time ago (admin mode) and overall I like it.

Administrator users in my opinion shouldn't be able to see the User Settings navigation item. Unfortunately Q485525 prevents this from happening easily. Or am I missing something that this should be visible to Administrator. Seems like only Configurator should see it.

Added By: Nate Laff at: 4/16/2013 2:29:56 PM    

Also, this has been an issue since the first iterations of this. If you make changes to the Win model at the highest level (Model.xafml) such as moving the location of MyDetails, these changes always get messed up. In the current scenario, MyDetails shows up in the navigation group I specified, but also gets duplicated in the default group after you logon with the Configurator user. Does this happen to anyone else?

Added By: Nate Laff at: 4/16/2013 3:03:33 PM    

Also, what's the process here? Let's say you want to make a global change to a view as Configurator..

Log on as Configurator
Make changes
Exit
Log on as Configurator
Manage User Settings action, import from source Configurator to all users
Exit
Log on as User
Verify changes

Is that the process? Am I missing something. The exits are required?

Also, you can't reset to defaults without opening Model Editor as configurator, resetting there, exiting, manage user settings and import from Configurator source again?

Just trying to make sure I have this process down correctly.

Added By: Nate Laff at: 5/2/2013 11:06:59 AM    

Dennis?

Added By: zacarias de prado habela at: 7/26/2013 4:31:49 AM    

Hi:
Where is "XPManageUserSettingsParameter", "XPUserSettings", XPUserSettingsAspect defined?
Thanks

Added By: Dennis (DevExpress Support) at: 7/26/2013 4:41:35 AM    

These classes are defined in the DatabaseUserSettings module. Use the Visual Studio search facilities to locate them...

Added By: Gabriel at: 9/24/2013 10:54:17 AM    

My happy day :D

Added By: Carlitos at: 1/4/2014 5:32:43 PM    

Quick question on the IMPORTANT NOTES:
1 - the bug was corrected right?
2 - Will there be a middle-tier and SecuredObjectSpaceProvider example?

Thanks

Carlitos

How to apply conditional formatting to a range of cells

$
0
0

This example illustrates how to get started with conditional formatting that can be applied to cells that match a certain condition specified by a conditional formatting rule.
In particular, this sample demonstrates how to use the SpreadsheetControl API to create the following types of conditional formatting rules:
- a rule that formats cells whose values are above or below the average;
- a rule that highlights cells whose values are between or not between two specified values;
- a rule that formats top or bottom ranked values;
- a rule that highlights cells containing the given text;
- a rule that formats unique or duplicate values, blank cells and formula errors;
- a rule that highlights cells containing dates in the specified time period;
- a rule that formats cells whose values meet the condition expressed by the relational operator;
- a rule that uses a formula to determine which cells to format;
- a two-color scale conditional formatting rule;
- a three-color scale conditional formatting rule;
- a data bar conditional formatting rule;
- an icon set conditional formatting rule.



How to apply conditional formatting to a range of cells

$
0
0

This example illustrates how to get started with conditional formatting that can be applied to cells that match a certain condition specified by a conditional formatting rule.

In particular, this sample demonstrates how to use the Spreadsheet Document Server API to create the following types of conditional formatting rules:

- a rule that formats cells whose values are above or below the average;

- a rule that highlights cells whose values are between or not between two specified values;

- a rule that formats top or bottom ranked values;

- a rule that highlights cells containing the given text;

- a rule that formats unique or duplicate values, blank cells and formula errors;

- a rule that highlights cells containing dates in the specified time period;

- a rule that formats cells whose values meet the condition expressed by the relational operator;

- a rule that uses a formula to determine which cells to format;

- a two-color scale conditional formatting rule;

- a three-color scale conditional formatting rule;

- a data bar conditional formatting rule;

- an icon set conditional formatting rule.

How to navigate through views by using NavBarControl control and NavigationFrame class

$
0
0

This example demonstrates how to implement navigation between views by using the NavBarControl control and NavigationFrame class.


ASPxGridView - How to display different controls in different cells of the specific column

$
0
0

Problem:
I have two columns in my ASPxGridView. The first column contains values. The second column should contain different controls/editors depending on the values in the first column.

Solution:
In this scenario you need to generate a template for the GridViewDataColumn.DataItemTemplate Property dynamically by implementing the ITemplate Interface. For instance:

[C#]
protectedvoidPage_Init(objectsender,EventArgse){((GridViewDataColumn)ASPxGridView1.Columns["UnitPrice"]).DataItemTemplate=newCustomTemplate();}
[C#]
publicclassCustomTemplate:ITemplate{publicvoidInstantiateIn(Controlcontainer){GridViewDataItemTemplateContainergcontainer=(GridViewDataItemTemplateContainer)container;intunits=Convert.ToInt32(DataBinder.Eval(gcontainer.DataItem,"UnitsOnOrder"));if(units== 0){ASPxLabellabel=newASPxLabel();label.ID="label1";gcontainer.Controls.Add(label);label.Text=DataBinder.Eval(gcontainer.DataItem,"UnitPrice").ToString();label.Width= 100;}else{ASPxSpinEditbutton=newASPxSpinEdit();button.ID="spinEdit1";gcontainer.Controls.Add(button);button.Value=DataBinder.Eval(gcontainer.DataItem,"UnitPrice").ToString();button.Width= 100;button.ClientSideEvents.LostFocus=string.Format("function(s, e) {{ grid.PerformCallback('{0}|' + s.GetValue()); }}",gcontainer.KeyValue);}}}

Here we display a simple label if the "UnitsOnOrder" field value is zero. Otherwise, we display a spin edit control with the editing capability.

See Also:
General information about Template containers

ASPxGridView - How to implement instant editing with check boxes in columns

$
0
0

This example illustrates how to implement instant editing in ASPxGridView. It is divided in two independent samples:

- The first sample (the Default1 page) illustrates how to post modified data to the underlying database on demand. Note that starting with v2013 vol 2, we provide a similar feature out-of-the-box: Batch Edit Mode.
- The second sample (the Default2 page) illustrates how to post modified data to the underlying database immediately.

In both samples, we define a custom GridViewDataColumn.DataItemTemplate with ASPxCheckBox. We handle the ASPxCheckBox' Init event (see The general technique of using the Init/Load event handler) to generate client-side ASPxClientCheckBox.CheckedChanged Event handler dynamically based on the current filed name and row key:

[C#]
// Default1.aspx.csprotectedvoidcb_Init(objectsender,EventArgse){ASPxCheckBoxcheckBox=(ASPxCheckBox)sender;GridViewDataItemTemplateContainercontainer=(GridViewDataItemTemplateContainer)checkBox.NamingContainer;stringkey=string.Format("{0}_{1}",container.Column.FieldName,container.KeyValue);checkBox.ClientSideEvents.CheckedChanged=string.Format("function(s, e) {{ hf.Set('{0}', s.GetChecked()); }}",key);}// Default2.aspx.csprotectedvoidcb_Init(objectsender,EventArgse){ASPxCheckBoxcheckBox=(ASPxCheckBox)sender;GridViewDataItemTemplateContainercontainer=(GridViewDataItemTemplateContainer)checkBox.NamingContainer;stringkey=string.Format("{0}|{1}",container.Column.FieldName,container.KeyValue);checkBox.ClientSideEvents.CheckedChanged=string.Format("function(s, e) {{ grid.PerformCallback('{0}|' + s.GetChecked()); }}",key);}

As you can see, in the first case we just save the modified value to the hidden field via the ASPxClientHiddenField.Set Method. These values will be extracted from it and posted to the database later when the "Save Changes" button is clicked. In the second case, we immediately initiate a saving callback via the ASPxClientGridView.PerformCallback Method.

See Also:
How to perform ASPxGridView instant updating using different editors in the DataItem template
How to implement the multi-edit functionality with a multi-page grid that is bound dynamically

Tutorial - Creating a registration form using ASPxEditors

$
0
0

This solution is created to illustrate the steps described in the Creating a registration form using ASPxEditors. Introduction tutorial series.


The solution consists of the following projects:

ASPxEditorsTutorial.Part1 - The resulting project for the Creating a registration form using ASPxEditors. Part 1 - Create the registration form layout article

ASPxEditorsTutorial.Part2 - The resulting project for the Creating a registration form using ASPxEditors. Part 2 - Customizing editors and adding a build-in client-side validation article

ASPxEditorsTutorial.Part3 - The resulting project for the Creating a registration form using ASPxEditors. Part 3 - Adding a Cascading Combo Boxes feature article

ASPxEditorsTutorial.Part4 - The resulting project for the Creating a registration form using ASPxEditors. Part 4 - Saving data to database article

ASPxEditorsTutorial.Part5 - The resulting project for the Creating a registration form using ASPxEditors. Part 5 - Implementing the password verification mechanism article

ASPxEditorsTutorial.Part6 - The resulting project for the Creating a registration form using ASPxEditors. Part 6 - Checking the entered email address article


BandedGridView - How to hide particular Bands

$
0
0

This example illustrates how to hide a particular Band and draw on its place column captions that belong to this Band.

Example Comments

Added By: Fajar Taufik at: 11/26/2013 11:56:14 PM    

I copied MyPaintHelper.vb to my project but can't run becouse error in MyBase.New(view) line, how to solve this problem

How to create a master-detail report bound to an ORM (Entity Framework) model in MVC applications

$
0
0

This example demonstrates how to create a master-detail report bound to Object Relational Model in ASP.NET MVC applications.

This example uses the Entity Framework ORM model to provide a report with data, but you can use any object model instead.

Bind your XtraReport to your model master class by using the approach suggested in the Providing Data to a Web Report => Design-Time Data Binding Using BindingSource help topic. After your report is bound to the master class you can easily insert a detail report band by using the context menu in the report designer, as shown below:

See also:
How to bind a report displayed in the DocumentViewer extension to the model's data

Viewing all 7205 articles
Browse latest View live


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