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

OBSOLETE - How to initialize an aggregated referenced property via an Action.


How to change the behavior of standard controller for only a specific object type

$
0
0

====================
This article is now obsolete. Refer to the Override Controller Behavior help topic instead.
====================
This example demonstrates how to change the New action's Caption property for only a certain business object in a Windows Forms XAF application.

How to show custom forms and controls in XAF (Example)

$
0
0

This example implements the following scenarios when an end-user clicks on a custom item in the navigation control:

- a custom non-XAF form is opened as a result;

- a standard XAF View containing a custom user control is opened as a result.


Both custom forms and user controls display persistent data from the XAF application database. For that purpose, this example solution provides a set of reusable elements (custom ViewItem and Application Model extensions) organized in a way that you can once implement them in an XAF module and reuse to display custom user controls in various forms.


Take special note that if you do not need your custom controls to display data from the application database or do not require a complex and reusable solution for this task,
you can use (recommended)a much simpler and built-in XAF solution - ControlDetailItemplaced within a DashboardView. Refer to the Using a Control that is not Integrated by Default article for more details.

If this is not your case, proceed to the instructions below:

1.
Define a base structure of the navigation control in your XAF application, as shown in the E911.Module\Model.DesignedDiffs.xafml file.

You can simply copy and paste the contents of the NavigationItems element into the corresponding file (pre-opened via the text editor) of your platform-agnostic module.

The same customizations can be achieved via the Model Editor visually.

This navigation structure will be further customized in the WinForms and ASP.NET executable projects later.


2. Intercept events of the navigation control to display a custom form when a custom navigation item is clicked.

To do this, implement a WindowController into your platform-agnostic module and handle events of the ShowNavigationItemController class as per the E911.Module\Controllers\ShowCustomFormWindowController.xx file. This controller will be abstract and be overridden in WinForms and ASP.NET modules.


3. Declare a custom ViewItem class that is supposed to host a custom user control in the standard XAF View. To do this, implement a custom ViewItem descendant and related types in the platform-agnostic module as shown in the E911.Module\Editors\CustomUserControlViewItem.xx file.

This ViewItem will also be abstract and platform-agnostic as it will not create platform-dependent controls, and will just provide a common customization code for both platforms. For instance, the OnControlCreated method will be overridden to bind the created control to data. To access persistent data from the database used by an XAF application, the ViewItem will implement the IComplexViewItem interface that consists of a single Setup method, receiving the IObjectSpace and XafApplication objects as parameters.

To unify our data binding code for both platforms, the IXpoSessionAwareControl interface and an auxiliary XpoSessionAwareControlInitializer class are introduced.

The interface provides a single UpdateDataSource method that is implemented by custom forms and user controls to bind them to data received by means of XPO.

You can use a similar mechanism and modify these auxiliary types to pass other custom data into your custom forms and controls.


4. Define a base structure of the standard XAF View with a custom ViewItem as shown in the E911.Module\Model.DesignedDiffs.xafml file.

You can simply copy and paste the contents of the Views element into the corresponding file (pre-opened via the text editor) of your platform-agnostic module.


5. Create custom forms and user controls in WinForms and ASP.NET executable projects analogous with what is shown in the example. The easiest way to do this is to copy the contents of the E911.Win\Controls and E911.Web\Controls folders and then include the necessary files into your solution. Take special note that these custom forms and controls implement the IXpoSessionAwareControl interface to automatically receive persistent data and other parameters when they are created.


6. Implement platform-dependent behavior to open and customize custom forms and controls. To do this, copy the following files into your WinForms and ASP.NET module projects:

WinForms:

E911.Module.Win\Controllers\WinShowCustomFormWindowController.xx - contains an WinForms version of the WindowController, which is inherited from the platform-agnostic

E911.Module.Win\Editors\WinCustomUserControlViewItem.xx - contains an WinForms version of the ViewItem, which is inherited from the platform-agnostic one;

E911.Module.Win\WinModuleEx.xx - contains a registration code for WinForms version of the ViewItem;


ASP.NET:

E911.Module.Web\Editors\WebCustomUserControlViewItem.xx - contains an ASP.NET version of the ViewItem, which is inherited from the platform-agnostic one;

E911.Module.Web\WebModuleEx.xx - contains a registration code for ASP.NET version of the ViewItem;

E911.Module.Web\Controllers\WebShowCustomFormWindowController.xx - contains an ASP.NET version of the WindowController, which is inherited from the platform-agnostic one;


These platform-dependent versions of the WindowController and ViewItem are required to implement the creation and display of custom forms and controls using the means specific for each platform. They are also designed to provide the capability to be able to set custom forms and control settings via the Model Editor. For that purpose, custom Application Model extensions are implemented for the Navigation Item and View Item model elements.


7. Set the custom forms and controls settings for each platform.

To do this, copy the contents of the E911.Win\Model.xafml and E911.Web\Model.xafml files into the Model.xafml file in the executable WinForms and ASP.NET projects:

WinForms:

ASP.NET:

 

IMPORTANT NOTES

1. It is also possible to mix the traditional and XAF development approaches (consult our Support Team if you are not sure how to integrate your standard non-XAF solution into XAF), because an XAF application is a regular .NET application built of reusable blocks like View, ViewItem, Property and List Editors, etc. that eventually create and customize platform-dependent controls exactly the same way you do this without XAF. So, using XAF does not mean something absolutely new and allows you to reuse your existing development skills and practices. Of course, it is possible to create your own reusable blocks if the standard ones do not meet your needs. For instance, the example of a custom View class designed to show a custom form can be found on CodeProject here.


2. This solution contains some generic code (e.g., base WindowController and ViewItem) that is mainly required because our XAF application is for both Windows and the Web. You may avoid this generic code and make a simpler implementation if you are developing for only one platform.


3. You can display custom forms not only when interacting with the navigation control, but from any other place. To do this, intercept the events of a required entity, e.g., an XAF Controller, Action or a View. Refer to the product documentation or consult with our Support Team in case of any difficulties.


4. By default controls layout and user customizations are preserved only for built-in XAF ListEditors, because they have special code for that. If you embed a custom user control into XAF, you need to preserve its settings yourself as well, exactly like you would do when implementing this task in the "old way" in a non-XAF application. Refer to the control's documentation to learn more on how to accomplish this task.

Feel free to contact the respective product team if you experience any difficulties customizing this control.

See also:
How to show custom forms and controls in XAF
How to create controls dynamically
How much of XAF's default UI is customizable.
How to Show a Window via an Action
How to: Display a List of Non-Persistent Objects
How to: Display a Non-Persistent Object's Detail View from the Navigation
ShowNavigationItemController.CustomShowNavigationItem Event
XafApplication.CustomProcessShortcut Event

Question Comments

Added By: kenngo at: 11/6/2012 2:24:10 AM    

Hi, I would like the custom from to be tabbedMDI, how to set this in the controller class?

Added By: Dennis (DevExpress Support) at: 2/1/2013 6:12:45 AM    

@Ngo Ken Hui:
Refer to the Q391718 ticket that describes a possible solution.

Added By: Alan mahone at: 4/26/2013 8:39:40 AM    

i have a problem in CustomUserControlViewItem.cs file
 in line "new XpoSessionAwareControlInitializer(Control as IXpoSessionAwareControl, theObjectSpace);"
the Control is converted to null

Added By: Dennis (DevExpress Support) at: 4/26/2013 8:43:18 AM    

Please submit a new ticket and attach your problematic project there:
http://www.devexpress.com/Support/Center/Question/Create
We will be glad to help you.

Added By: Andrew Bingham 2 at: 6/5/2013 10:11:58 AM    

The downloaded solution states it is for " v13.1".

The latest version I am aware of is 12.2?

Added By: Carl Howarth 1 at: 10/11/2013 4:00:36 AM    

Just in case anyony else hits the issue where the model.CustomControlTypeName is null; there are some additional model settings that are not included in the example code below (but are in the actual download).

Have a look at the XML for the E911.Module.Win/Web Model.xafml. You will notice that there are settings within these files that are not detailed below (it may be obvious to some based on the article but I missed it and it cost me the best part of a day).

Win version:
<Application>
  <NavigationItems>
    <Items>
      <Item Id="Default">
        <Items>
          <Item Id="CustomForm" CustomFormTypeName="E911.Module.Win.Controls.WinCustomForm" />
        </Items>
      </Item>
    </Items>
  </NavigationItems>
  <Views>
    <DashboardView Id="StandardFormWithCustomUserControl">
      <Items>
        <CustomUserControlViewItem Id="CustomUserControlViewItem" CustomControlTypeName="E911.Module.Win.Controls.WinCustomUserControl" />
      </Items>
    </DashboardView>
  </Views>
</Application>

Web version:
<Application>
  <NavigationItems>
    <Items>
      <Item Id="Default">
        <Items>
          <Item Id="CustomForm" CustomFormPath="Controls/WebCustomForm.aspx" />
        </Items>
      </Item>
    </Items>
  </NavigationItems>
  <Views>
    <DashboardView Id="StandardFormWithCustomUserControl">
      <Items>
        <CustomUserControlViewItem Id="CustomUserControlViewItem" CustomControlPath="Controls/WebCustomUserControl.ascx" />
      </Items>
    </DashboardView>
  </Views>
</Application>

Hope this helps.

Cheers

Carl

How to create a custom search panel

$
0
0

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

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

To find a location 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.


Question Comments

Added By: KoenVerbeeck at: 8/6/2014 5:03:41 AM    

Hi,
Cannot make this work.. Lot of undefined classes, for example InformationLayer is not known..
I added using DevExpress.XtraMap + referenced the XtraMap assembly..
What is missing?
Regards,
Koen

Added By: KoenVerbeeck at: 8/6/2014 5:05:38 AM    

PS: tried to download the example but cannot open a dxsample file..

TreeList - How to drag and drop nodes between two treelists

$
0
0
This example demonstrates how to drag and drop nodes between two treelists. To do so, each extension has its client-side StartDragNode and EndDragNode events handled to:

- Add new drop targets for the node being dragged;
- Perform a callback to the server to update the state of both treelists.

This logic is implemented inside the MyDragHelper.js file.

How to search for objects by using all the properties or by using more complex criteria

$
0
0

This example provides a possible workaround for the Filtering - Support searching objects by a string through all the properties (or a set of properties) or by more complex criteria suggestion.
The Dennis.Search.Win module, shown in the example, provides API to create a non-persistent object that can be used to search by properties of a business class. Such a non-persistent search-object should implement the ISearchObject contract. By default, it's supported by the abstract and generic SearchObjectBase class in the module. Search-objects are shown in a Detail View with the help of the SearchObjectViewController. To compose a search criteria, a specific SearchObjectPropertyEditor is used (it contains the Search and Clear buttons).
An example use of the implemented module is illustrated in the WinSolution.Module.Win module. There is a ProductSearchObject class that is inherited from the base SearchObjectBase class. If necessary, you can create several search objects for one business class. In UI, all search objects will be listed in a drop-down list in the toolbar of a View of your business class. Download and run the attached example to see how this works in action.
(Take special note of the SearchObjectBase class implementation, because it asynchronously loads search results of a specific type from the data store into the Search Results nested List View.)

Note that if you are implementing this functionality in ASP.NET, it is necessary to set the WebApplication.CollectionsEditMode property to Edit. Otherwise, the search results will not be displayed.

 

See Also:
How to allow users to create filter via the criteria editor before previewing a report
How to use Criteria Property Editors

Question Comments

Added By: Taradanov at: 6/17/2012 8:28:29 AM    

Can you provide Web editor for this example, please?

Added By: Gavin Lipeng Ma at: 3/20/2013 7:50:39 PM    

Also need a web solution.Could you please provide a web solution for this ?

Added By: kenngo at: 5/30/2014 10:49:42 PM    

The SearchObjectBase[Product]_SearchResults_ListView in the Model Editor is autogenerated? How is the search result link to this view?

Added By: Dennis (DevExpress Support) at: 6/2/2014 2:34:35 AM    @kenngo: Yes, it is auto-generated by XAF. This is a nested ListView node, which corresponds to the SearchResults collection property of the SearchObjectBase class, which is used to display results in the UI.

How to implement CRUD operations with a DataSource

$
0
0

This example demonstrates how to implement CRUD operations with a DataSource that obtains data from a remote Rest service. The DataSource object does not implement CRUD operations out-of-the-box. We can do this using jQuery.ajax. It is also necessary to call the DataSource.load method to "inform" your widget that it is necessary to reload its content.

See also:
Connect to RESTful Service
How to implement the Rest service based on an ASP.NET WebAPI application
dxDataGrid - How to implement a custom store with CRUD operations

Question Comments

Added By: Leovin S at: 8/20/2013 3:38:42 AM    

Thank you for the code.But the problem is that it is related to data that is retrieved through the service.I tried getting my data retrieved from my json file but then it shows errors.
So ,if you could give me a stand alone project ,including the data base I would be able to understand very clearly.

Added By: pedro azpurua at: 2/18/2014 5:59:29 AM    

I M P R S S I V E after four months working with OData this sample is the Nirvana

Added By: Muhammad Syarif at: 6/10/2014 7:27:29 PM    

this tutorial very good.but when i try it and run i get message "No data display" in my emulator.why that happen??
please help me.thank you.

Added By: Muhammad Syarif at: 6/10/2014 9:50:16 PM    

hello devexpress.
i download this source code and run it, i change the destination of database to http://localhost:9839/DataService.svc/Categories
but i just get Loading in my emulator. what the wrong, please help me.thank you

Added By: Nikolai (DevExpress Support) at: 6/10/2014 11:16:47 PM    Hi,

Please test this example with How to implement the Rest service based on an ASP.NET WebAPI application.

dxDataGrid - How to implement a custom store with CRUD operations

$
0
0

The dxDataGrid binding using a CustomStore help topic and the A custom data source does not apply paging, filtering, sorting and grouping article describe how to implement a custom data source that loads data for a dxDataGrid . This example demonstrates how to make a custom store for the dxDataGrid widget manipulate data. For this purpose, we need to implement the insertupdate and remove methods in our custom store. Each of these methods will be called automatically by the widget. 

The insert method accepts a parameter that contains values for a new item. The update method accepts two parameters: the first one is a key value of the editing row, and the second one contains values of modified data fields. The remove method accepts a parameter that contains a key value of the deleted row. When a method is called, we need to send a corresponding request to our data service and pass the required parameters. We use jQuery.ajax for sending requests to our data service. This example can be tested with a data service from How to implement the Rest service based on an ASP.NET WebAPI application.


See also:
Deferred Object
jQuery.extend
How to implement CRUD operations with a DataSource

How to show and hide a popup window via server side code

$
0
0

While we recommend using client-side code (scripts) to open or hide a popup window to avoid a turn around to the server, in certain situations you may need to implement server-side processing before opening and after closing the popup window. This example demonstrates how to change the popup control's visibility via server code.

See Also:
ASPxPopupControl - How to implement OK and Cancel buttons for a modal popup window

Question Comments

Added By: ehemmer at: 1/30/2013 4:32:51 PM    

What about when the content of the popup are also in an update panel? Unless the popup is also in the same update panel it won't close will it?

Added By: Andrew Werner 1 at: 8/15/2013 12:05:26 PM    

I wish very much that I could somehow see how this works

Added By: Paul.Astramowicz@thyssenkrupp.com Paul.Astramowicz@thyssenkrupp.com at: 8/6/2014 3:29:11 PM    

How does the VB.net code look to make the popup pop up server side?

How to: Create a Custom Control Detail Item

$
0
0
The complete description will be available in the documentation with the next minor release.

How to: Implement a Custom View Item

$
0
0
The complete description will be available in the documentation with the next minor release.

How to drag and drop nodes between two ASPxTreeList controls

XtraMap Getting Started - Lesson 2 - Connect to OpenStreetMap

XtraMap Getting Started - Lesson 1 - How to load image tiles from Bing Maps

$
0
0

This example demonstrates how to connect to Bing Maps using the BingMapDataProvider object.

Note that if you run this sample as is, you will get a warning message informing 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 Key tutorial.


XtraMap Getting Started - Lesson 3 - Binding a map control to data loaded from XML

$
0
0

This example illustrates how to bind a Map control to data. This data stored in an external XML file, which contains information about wrecked ships, including ship coordinates.

In this example, the map control automatically generates ship images based on data from the datasource, along with a description for each image in a tooltip.

Question Comments

Added By: Stefán Höskuldsson at: 8/21/2013 2:57:31 AM    

In this example below you are always using the same image for each item. If I wanted different images (like based on type of ship) could I somehow use the MapItemAttributeMapping to map to an Image or an ImageIndex in the Ship class?


How to get joined tables from the LinqServerModeDataSource using a custom LINQ query

$
0
0

This example demonstrates how to get joined tables from the LinqServerModeDataSource by using a custom LINQ query.
In the example the server-side LinqServerModeDataSource.Selecting event was handled and the QueryableSource property was used to specify the required LINQ query expression.


Question Comments

Added By: Nicholas Anson at: 8/7/2014 7:42:00 AM    

Using this event is nice for applying selection criteria, but does the "application" still benefit from LinqServerModeDataSource, despite the use of this event? Or, will the application perform faster using the LinqServerModeDataSource1.TableName = table.ToString, and then applying the ASPXGridView1.FilterExpression concept? Please advise

Added By: Sergi (DevExpress Support) at: 8/7/2014 11:15:05 AM    Hi,

It seems that you have posted a similar question in the context of the T138156: LinqServerModeDataSource ticket. We will reply you there.

How to implement data paging

$
0
0

Silverlight supports the data paging mechanism natively. In the meantime, there are no easy approaches to implementing the IPagedCollectionView interface in WPF.


The easiest way to implement data paging is to change the grid's ItemsSource when the page index is changed. This example contains special attached behavior that allows you to enable this feature with ease.

Question Comments

Added By: Ravickumar Murugesan at: 8/23/2013 3:00:35 PM    

With this implementation the search behavior is not normal.

Added By: Alexander (DevExpress Support) at: 8/25/2013 11:27:33 PM    

Hello,

I have checked the Search Behavior with this solution using version 13.1.6, and it appears that everything works as expected. Searching operates only for the current page. If you have other behavior on your side, would you please describe the issue in greater detail?
P.S. Please create a separate ticket to clarify this moment. If we find an issue with the provided solution, we will update it.

Added By: f22raptor at: 2/4/2014 9:53:13 AM    

I getting NULL exception at this line:
 DataPager.ItemCount = Sources.Count;

Added By: Michael Ch (DevExpress Support) at: 2/5/2014 6:19:48 AM    

Hello,

We have moved your question to a separate thread: Q466351 thread. Please refer to it for further discussion.

Added By: kumar gaurav 8 at: 8/7/2014 11:51:08 PM    

this solution is not working because the GetValue(sourceproperty) gives null

Added By: Alexander (DevExpress Support) at: 8/8/2014 2:37:17 AM    

Hi Kumar,

I've noticed that there is a separate thread with the same question from you: How to implement paging in dxg:GridControl using dxe:DataPager. We will answer in that ticket as soon as possible. Please give us some time.

How to apply master filtering in MVCxDashboardViewer

$
0
0

The following example demonstrates how to apply master filtering in MVCxDashboardViewer on the client side.


In this example, the ASPxClientDashboardViewer.SetMasterFilter method is used to select required rows in the Grid dashboard item. The SettingsBase.Name property value is used to access the extension client object on the client side.
Click the SetMasterFilter button to apply master filtering.

How to get all GridView selected keys and pass them to a Controller

$
0
0

This example illustrates how to collect all selected values (for example, keys) on the client side via the ASPxClientGridView.GetSelectedFieldValues method and pass them to:
- The GridView callback action via the e.customArgs dictionary (Passing Values to Controller Action Through Callbacks);
- Any controller post action via a hidden input element.

Question Comments

Added By: hernan bogantes at: 12/6/2013 7:28:25 AM    

I checked your sample against my code and the only difference is the line below. But if when I added it, it grid crash., which means the screens do not render the grid.
settings.ClientSideEvents.SelectionChanged = "OnSelectionChanged";
----------------------------------------------
I am still having the same issue.

Added By: Rufus Buschart at: 6/23/2014 8:36:30 AM    

Maybe I don't understand the example correctly, but I would have expected, that in GridViewEditingPartial.cshtml is a line "settings.ClientSideEvents.BeginCallback = "OnBeginCallback";" passing the selected values to the controller. But there is none. Maybe this example is broken?

Added By: Anthony (DevExpress Support) at: 6/23/2014 12:19:48 PM    Hi Rufus,

We will provide you with an answer in the http://www.devexpress.com/Support/Center/Example/Details/E20065 seems to be broken ticket.Added By: Patrick Winkler at: 8/11/2014 12:57:55 AM    

How can I do this with nested grids? Basically a nested row selection grid.

There must be unique grid names, but on parsing them on the client side in javascript I cannot select values from dynamic named grid's.

Any idea?

Thanks, Patrick

Added By: Mike (DevExpress Support) at: 8/11/2014 1:07:34 AM    

Hello Patrick,

To process your recent post more efficiently, I created a separate ticket on your behalf: T138875: E20065: How to get all GridView selected keys and pass them to a Controller / Master Detail. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to perform a drill-down in DashboardViewer

$
0
0

The following example demonstrates how to perform a drill-down in DashboardViewer.

In this example, the DashboardViewer.PerformDrillDown method is used to perform a drill-down for a specified row in a Grid dashboard item. This method is called in the SelectedIndexChanged event handler of the combo box.
The DashboardViewer.PerformDrillUp method called in the Click event handler returns the Grid dashboard item to the top detail level.




Viewing all 7205 articles
Browse latest View live


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