It is necessary to use the PivotGridControl.HeaderMenuCustomizations to add custom items to a default context menu.
How to provide custom menu items to allow SummaryType and SummaryDisplayType runtime selection for a specific Data Field
How to print a report without displaying it in a web application
This example illustrates the approach of printing report document directly, via Adobe PDF web browser plug-in.
This can be done by sending the exported XtraReport document via the Page.Response.OutputStream.Write method, and setting the PdfExportOptions.ShowPrintDialogOnOpen property to True.
How to track changes made to persistent objects, and write them into a separate table
The OnSaving and OnDeleting method of the persistent objects can be overridden to log create/update/delete actions into a separate table. This example demonstrates the basic implementation of this feature.
Note: eXpressApp Framework have built-in module for Audit purposes. This example demonstrates how to use this module in non XAF application: How to use XAF Audit Trail module outside XAF.
GridView - How to bind a master-detail grid to search results
This example demonstrates how to pass search parameters to the master grid Partial View and pass the master row key to the detail grid Partial View to bind grids to correct data.
In the "Index" View, search parameters are passed to the View as a Model. So, when the "Search" Button is clicked, the model is submitted.
To pass search parameters to the master GridView, I have used the action route values collection. Then, in the "OrdersGridPartial" action, these parameters are used to get the correct Model, which will be used to bind the master GridView to the search result. To pass these parameters to this action on a GridView callback, I have passed them to the GridViewSettings.CallbackRouteValues collection by using the ViewData.
The same approach is used to pass the master row key to the detail GridView and bind it to the correct detail data.
How to use GaugeControl as an in-place editor
This sample illustrates how you can embed your GaugeControl into the GridControl.
How to create a Pie chart
The following example demonstrates how to create a Pie chart at runtime.
Note that this series view type is associated with the Simple Diagram type, and you should cast your diagram object to this type, in order to access its specific options.
Dealing with Pie charts, you may also find the following documents useful:
- How to: Show Values as Percents in the Legend of a Pie Chart;
- How to: Show N Top Points as a Single Section in a Pie Chart.
Example Comments
Added By: Eric Joe at: 7/8/2013 6:50:36 AM
Dear all, could anyone guide me how to cast the diagram object to this form?
Thank you.
How to implement a week number panel in the Month view
This example shows how to implement a custom panel that will show week numbers for the Month view.
You can include the WeekNumberControl into your application, put it next to the SchedulerControl, set its height like in the scheduler, and put your SchedulerControl into its Scheduler property.
How to create a multilevel numbered list in code
This example illustrates how to create a numbered list in code.
Add a new AbstractNumberingList instance to the Document.AbstractNumberingLists collection.
Specify a NumberingListBase.NumberingType property, so that it is equal to the NumberingType.Multilevel value.
For each list level, specify the paragraph characteristics using the ListLevel.ParagraphPropertiesListLevel.ParagraphProperties property. Set the left indentation so that each level has a different offset from the left. Specify a hanging first line and set the first line indent value to provide enough space for a number that precedes the text. Set the starting number value. Specify a format used to display a number via the NumberingFormat property.
Use the Add method of the collection of lists in the document (accessible via the Document.NumberingLists property) to add a list definition to the document. The parameter is the index of an abstract numbering list created previously. The Add method creates a pattern that can be applied to a paragraph so that the paragraph looks like a list item.
To include a paragraph in a list, set the ListIndex property of a paragraph to the index of a list in the document and specify the ListLevel property.
How to implement CRUD operations with a DataSource
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 necessary to add the changed option that represents the jQuery.Callbacks object. It is also necessary to call the changed.fire method to "inform" your widget that it is necessary to reload its content.
See also:
How to implement the Rest service based on an MVC WebAPI application
How to implement the Rest service based on an MVC WebAPI application
This example demonstrates how to implement the Rest service based on an MVC WebAPI application.
See also:
How to configure ODataService for a DevExtreme HTML5/JS application
Creating a REST service using ASP.NET Web API
An Introduction To RESTful Services With WCF
How to implement CRUD operations with a DataSource
How to show custom forms and controls in XAF (Example)
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 form and user controls display persistent data from the XAF application database:
To accomplish this, you can follow 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;
one;
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:
That is it.
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: Invoke a List View for a Non-Persistent Class
How to: Display a Non-Persistent Object's Detail View from the Navigation
ShowNavigationItemController.CustomShowNavigationItem Event
XafApplication.CustomProcessShortcut Event
Example Comments
Added By: kenngo at: 11/6/2012 5: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 9:12:45 AM@Ngo Ken Hui:
Refer to the Q391718 ticket that describes a possible solution.
i have a problem in CustomUserControlViewItem.cs file
in line "new XpoSessionAwareControlInitializer(Control as IXpoSessionAwareControl, theObjectSpace);"
the Control is converted to null
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.
The downloaded solution states it is for " v13.1".
The latest version I am aware of is 12.2?
How to change foreground and background colors of a highlighted text corresponding to a search string of Find Panel
This example illustrates how to customize foreground and background colors of a search string highlighted within located records in a grid.
How to switch ASPxGridView between certain data sources (LinqServerModeDataSource and EntityServerModeSource) at runtime
This example demonstrates how to use the same grid to view different data sources. The grid's column is autogenerated.
Please note that the ViewStateMode property should be disabled to allow the grid to work properly.
DXTreeList - How to implement group footers
At the moment, our TreeListView does not provide the capability to show summary footers for its groups. This example demonstrates how to implement this functionality manually by using a custom DataRowTemplate.
This workaround has a few limitations:
1. It supports only a two-level structure.
2. The context menu for summary footers is not supported.
3. The grid's horizontal scrolling is not supported.
How to include a deleted row KeyField value into the delete confirmation dialog
This demo demonstrates how to include the Delete link into a column's DataItemTemplate Container, and fetch information about the clicked row to the delete confirmation dialog
See Also:
How to implement a delete confirm dialog with a "don't ask me again" option
ODataContext - How to filter data by a foreign key value
Sometimes it is required to filter some entities by a foreign key value.
This example demonstrates how to select all products that are associated with a required category. The Product entity has the Category navigation property. To filter products by the category ID, we need to expand the Category property using the ODataStore.expand option. In this case, we will be able to access a key field of a navigation property. This example operates with the Northwind online OData service. We can determine that Category is a navigation property of the Product one by typing the following URL in our browser "http://services.odata.org/Northwind/Northwind.svc/$metadata". See a screenshot below.
In this case our code should be as follows:
[JScript]TestExpand.db = new DevExpress.data.ODataContext({ url: "http://services.odata.org/Northwind/Northwind.svc", errorHandler: function(error){ alert(error.message);}, entities: { Products: { key: "ProductID"}}});var viewModel = { dataSource: TestExpand.db.Products.toDataSource({ select: ['ProductID', 'ProductName', 'Category.CategoryID', 'Category.CategoryName'], expand: ['Category'], filter: ['Category.CategoryID', '=', 5]})};
dxList - How to scroll to a specific item
dxList does not provide any API that allows scrolling to an item. We can create a dxList inheritor and add the required functionality. This example demonstrates how to add the dataBound event and a method that scrolls content to a specific item index.
[JScript]var MyList = DevExpress.ui.dxList.inherit({ _render: function(){this.callBase();if(this._dataSource){if(this._dataSource._isLoaded && $.isFunction(this.option("dataBound")))this.option("dataBound")(this);}}, scrollToItemIndex: function(index){var elements = this._items();if(elements.length < index || index < 0)return;var itemHeight = elements[0].offsetHeight;this._scrollView.scrollPos(itemHeight * index, true);}}); DevExpress.ui.registerComponent("myList", MyList);
We handle the dataBound event and call the scrollToItemIndex method that was added to our inheritor.
See also:
DevExpress.ui.registerComponent
SpreadsheetControl API Part 02
This example demonstrates how to use the SpreadsheetControl API to programmatically manage spreadsheet documents.
This sample introduces API properties and methods used to perform the following operations:
- Insert and manage pictures
- Create custom spreadsheet functions
How to enhance performance when handling a large number of appointments
Problem:
The Scheduler behaves perfectly well when there is a reasonable amount of appointments to display. However, what if I am required to handle large appointment datasets? If I use the ObjectDataSource, then all data are loaded when a page is being created. That means that the application is fetching unnecessary data, increasing server workload and degrading the overall performance. It is suggested that in this case the FetchAppointments event should be used to narrow the time frame for which appointments should be retrieved. However, how does one get the newly selected time interval in the page cycle before the ObjectDataSource retrieves data from the underlying data source?
Solution:
This example illustrates the use of the FetchAppointments event to limit the number of appointments loaded at a time to the appointments actually shown. To achieve this, a new data source control is created by using the ObjectDataSource. This control implements its own CRUD procedures for appointment and resources. It enables you to intercept requests for visible interval changes and load only necessary data.
Note that page rendering performance is highly affected by the browser type. Internet Explorer seems to be the slowest one, so it is recommended to view the example using FireFox.
P.S. If you run this example online, the scheduler is in read-only mode, so no modifications or new appointment insertion are allowed.
Example Comments
Added By: Marc Michaels at: 7/24/2013 10:08:23 AM
I think this is the single biggest performance enhancement strategy for the aspxscheduler control! I may not have been looking hard enough, but it took me months (and the purchase of a new database server) to find this little gem. Performance of my aspx scheduler went from several seconds per operation to near-instant.
To me, this information is so vital to efficient operation of the aspxscheduler control, it should be published, blogged, and disseminated in as many ways as possible to make it easy to find. Heck, find a way to sticky post it in the support center kb search or something.
ASPxUploadControl - How to convert a binary image to a base64 string
The data URI scheme is an URI scheme (the Uniform Resource Identifier scheme) that provides a way to include data in-line in web pages as if they were external resources. Data URIs are a form of Uniform Resource Locators, although they do not in fact remotely locate anything. Instead, the resource data is contained within a URL string itself as a base64-encoded string. This saves the browser from having to make additional HTTP requests to external resources, and can thus increase page loading speed.
This online example allows you to upload an image using the ASPxUploadControl and convert the image into a base64 encoded data URI for embedding images into html or css.
Your image elements will look as follows:
[HTML]<imgsrc="your_image_bytes_in_base_64"/>