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

How to use HTML5 Document Viewer within a DevExtreme application

$
0
0

Starting with version 16.1.9, this example illustrates how to integrate the HTML5 Document Viewer into a DevExtreme-based Single Page Application project.
 
This example consists of these two projects.
1. Frontend - a DevExtreme project (prior to version 16.1.9, this was a pure HTML5 client) that includes all necessary styles, scripts and HTML-templates required by the Document Viewer.
2. Backend - an MVC 4 application in two implementations: using the Web API Controller and MVC Controller. At the backend, cross-domain requests are enabled (Access-Control-Allow-Origin) and a custom report resolver is implemented (CustomReportResolver).

To learn about the previous implementation (prior to version 16.1.9), watch the following webinar video online: DevExpress Reports in Client-Side Web Apps.


How to delete grid rows via the DeleteFocusedRow grid command

$
0
0

The following example demonstrates how to add a Delete item to the grid cell's context menu.

Question Comments

Added By: Berto at: 5/23/2012 7:14:27 AM    

If the grid is empty a binding error occurs: System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=grid'. BindingExpression:Path=View; DataItem=null; target element is 'BarButtonItem' (HashCode=33829902); target property is 'CommandTarget' (type 'IInputElement')

Added By: Sebastian Wróbel 1 at: 1/7/2014 2:51:32 AM    

Example is not working, row is not deleted. Ver 13.2

Added By: Artem Dubenko 2 at: 12/22/2016 8:25:42 AM    It would be nice if you had a 'DeleteSelectedRows' command too.Added By: Elliot (DevExpress Support) at: 12/22/2016 8:29:35 AM    

Hello Artem ,

I've created a separate ticket on your behalf (T465830: There is no DeleteSelectedRows command in the grid control). It has been placed in our processing queue and will be answered shortly.

Thanks
Elliot

How to use custom controls for editing report content in Print Preview

$
0
0
This example demonstrates how to create and register custom editors to be used for editing the content of report controls in Print Preview. In particular, it shows how to create a combo box editor, a date editor with a custom format and a standard text editor with a phone number mask.

The following image illustrates a custom combo box editor.



Question Comments

Added By: Greyce at: 12/22/2016 8:16:50 AM    Is it possible, after change the value of the fields save it in the database?
Added By: Vasily (DevExpress Support) at: 12/22/2016 9:54:00 AM    

Hi Greyce,

To avoid discussing multiple topics in this thread, I have extracted your question to a separate ticket created on your behalf: T465862: How to save the report's field value to the database). It has been placed in our processing queue and will be answered shortly.

How to implement dependent views in a DashboardView (filter based on selection)

$
0
0

This example illustrates how to filter a ListView displayed in a DashboardView based on another ListView's selection.

Scenario
When a DashboardView contains several list views, it is often required to make them dependent, e.g. display items of one ListView based on items or selection of another ListView.

Steps to implement
1. Add a new ViewController to your platform-agnostic module (DashboardFilterController).
2. In the OnActivated method retrieve the necessary DashboardViewItems via the FindItem method. After that subscribe to the ControlCreated event of the DashboardViewItem whose ListView will be used for filtering (hereinafter referred to as SourceView).
3. In the ControlCreated event handler retrieve the SourceView via the DashboardViewItem.InnerView property and subscribe to its SelectionChanged event.
4. In the SelectionChanged event handler retrieve the View that will be filtered (hereinafter referred to as TargetView) in the same manner as in the previous step.
5. To retrieve an object by which filtering will be performed, use the ListView.CurrentObject property. This object must be loaded from SourceView ObjectSpace to TargetView ObjectSpace via the GetObject method.
6. Now you can simply filter the TargetView by adding CriteriaOperator to the TargetView.CollectionSource.Criteria dictionary. In my example, I created a simple InOperator to filter the Position column via objects from SourceView.

Important notes:
The provided algorithm is platform-agnostic. It will work without any additional code in WinForms applications, but in ASP.NET the TargetView will not be refreshed immediately after changing the SourceView's selection. It is required to post changes made on the server side to the client to show them in the browser. That is why I have implemented the DashboardViewRefreshController that will refresh DashboardView when selection in the SourceView is changed. Handle the WebWindow.CurrentRequestWindow.PagePreRender event. In this event handler, find the ASPxGridView, modify its client-side SelectionChanged event and the script using the CallbackManager as shown in the DashboardRefreshController.cs file.
Then deactivate the RecordsNavigationController to prevent its activation for the TargetView in the DashboardView. This controller can lead to an exception during navigation to the record's DetailView on a click in the SourceView. This behavior is caused by the fact that RecordsNavigationController lies inside the ListView and collects information about records when this ListView is disposed of. It collects records based on visible rows, but since we filter the CollectionSource, it does not contain the required object.

Question Comments

Added By: Bram Essers at: 3/6/2014 1:12:31 AM    

Hi,
Thanks for this clear example. Together with the supplied source code it is easy to follow. I do have a question. I was testing the functionality in the Web Application solution. When I change the selection in the source grid via the check boxes everything works fine. However, when I click on a row in the source grid I get an exception (see below). What can be done to fix this issue?

Regards,
Bram

The error occurred:

     Type: ObjectDisposedException
     Message: Cannot access a disposed object.
Object name: 'DevExpress.ExpressApp.NestedFrame'.
     Data: 0 entries
     Stack trace:

   at DevExpress.ExpressApp.Frame.CheckIsDisposed()
   at DevExpress.ExpressApp.Frame.SetTemplate(IFrameTemplate val)
   at DevExpress.ExpressApp.Editors.DashboardViewItem.BreakLinksToControl(Boolean unwireEventsOnly)
   at DevExpress.ExpressApp.CompositeView.BreakLinksToControls()
   at DevExpress.ExpressApp.View.b__2()
   at DevExpress.Persistent.Base.SafeExecutor.Execute(Method method, Object targetObject, String targetObjectIdentifier)
   at DevExpress.ExpressApp.View.Dispose()
   at DevExpress.ExpressApp.Frame.DisposeView(View view)
   at DevExpress.ExpressApp.Frame.SetView(View view, Boolean updateControllers, Frame sourceFrame)
     InnerException is null

Added By: Alexey (DevExpress Support) at: 3/6/2014 1:39:56 AM    

Hello Bram,
I will answer you in the Q467603 thread

Added By: Marc Greiner (DevExpress MVP) at: 9/22/2016 12:36:37 AM    For a solution that additionally works with ViewVariants, have a look at:
https://www.devexpress.com/Support/Center/Question/Details/T429995
Added By: Randy Jean at: 12/22/2016 12:20:49 PM    I have this working in a Winforms app, however, when the detailListview is displayed the last row is focused/selected.  Any way to make the first row selected/focused (or no rows selected)?

How to add a check box to a gallery item

$
0
0
This example illustrates how to add the CheckContextButton to each Gallery item and handle the click of this context button.

How to fix a row in GridControl

$
0
0

In this example, it's demonstrated how to fix a row in GridControl so that its position is preserved even when the grid is being scrolled. To show a button that fixes a row, use the ShowFixRowButton property. If you wish to add fixed rows from your view model, bind to the FixedTopRows or FixedBottomRows collections. 
TableView provides commands for fixing rows: FixRowToTop and FixRowToBottom. Please note that it's necessary to pass the row that you wish to fix to the command parameter.

Question Comments

Added By: Yuriy Plitman at: 8/25/2016 4:08:52 AM    Hi,

Thanks for the example.
However in my case I need explicitly excluded variant with conditional formatting. The celltemplate of my fixed row is assigned by CellTemplateSelector.

What should I do in this case?

Many thanks in advance.

Regards
Yuriy
Added By: Alexander Rus (DevExpress Support) at: 8/25/2016 8:23:21 AM    

Hello Yuriy,
I've created a separate ticket on your behalf (T419250: Fixed rows in GridControl). It has been placed in our processing queue and will be answered shortly.

Thanks,
Alexander

OBSOLETE: LayoutControlItem - How to implement the HighlightFocusedItem property at the item level

$
0
0
Starting with version 16.2, LayoutControl supports highlighting the currently focused item out-of-the-box. Use the LayoutControlItem.HighlightFocusedItem property for this.

The example demonstrates how to implement the HighlightFocusedItem property for a layout control item. 
In this example, a LayoutControl descendant is created to implement the required logic. Here are the main implementation points:
1. The HighlightFocusedItemEx property is introduced to the LayoutControlItem class.
2. In a custom item skin painter (CustomLayoutControlItemSkinPainter), the PatchImageIndexCore method is overridden to provide the required image index based on the controlItem.HighlightFocusedItemEx property.

Please note that the highlight focused item feature is actual in the skinned painting scheme only; i.e., when the LayoutControl.LookAndFeel.Style property is set to Skin.

OBSOLETE: How to register your own GroupObjectPainter in the LayoutControl.

$
0
0

Starting with version 16.2, LayoutControl provides the possibility to custom paint individual items out-of-the-box. Handle the LayoutControl.CustomDraw event for this.


These are the steps required to accomplish this task:

1. Create a custom painter for the necessary element.
2. Inherit from the LayoutPaintStyle object and override, as appropriate, either the GetXXXPainter() or the CreateXXXPainter() method.
3. Create the LayoutControlImplementor descendant and override its InitializePaintStyles() method. Within this method replace any paint style with your own.
4. Create the LayoutControl descendant and override its CreateILayoutControlImplementorCore method to return your own LayoutControlImplementor object.

Please see the code example for detail.


OBSOLETE: How to implement Custom Drawing capabilities in the LayoutControl

$
0
0

Starting with version 16.2, LayoutControl provides the possibility to custom paint individual items out-of-the-box. Handle the LayoutControl.CustomDraw event for this.

This example demonstrates how to create a custom style, and manually draw specific LayoutControl's items.

OBSOLETE: How to create LayoutControlItem's with predefined quantity rows and columns at runtime

$
0
0

Starting with version 16.2, LayoutControl provides the new mode Table Layout Mode. It is a two-dimensional grid that consists of cells formed by a set of rows and columns. Each layout item is arranged in table cells according to its row and column indexes and span values.

 

This sample illustrates how to create layout items at runtime. Layout items are created in the BeginInit/EndInit block. This improves performance. If you specify item bounds yourself, and place your code in the BeginInit/EndInit block, the LayoutManager doesn't recalculate item bounds inside this block, but you must make sure that you don't have any gap between your layout items.The AddRange method was used to add a layout item array.

How to enable an Excel-like filter dropdown

$
0
0

This example demonstrates how to enable an Excel-like filter dropdown in different DevExpress versions.

In version 16.2, we have implemented the Excel Style Filtering functionality out of the box. This mode can be enabled by setting a single property - FilterPopupMode.

In previous versions, where this functionality is not available out of the box, it is possible to filter dropdown items based on the current filter.
First, DXGrid has the built-in ShowAllTableValuesInCheckedFilterPopup property that allows enabling the following mode:
- If the current column is not filtered, the filter dropdown displays only those items that meet the grid's filter condition.
- Otherwise, all data source items are displayed to simplify the process of the grid filter correction.
If this functionality is insufficient, and filtering dropdown items when the current column is filtered is required, use the approach demonstrated in this example. See the Implementation Details section for more information.

Question Comments

Added By: PraveenKumar Kuppuswamy at: 11/24/2016 8:34:51 PM    Hi

The Below solution is not working for me.

Thanks
Praveen Added By: Andrey Marten (DevExpress Support) at: 11/24/2016 10:42:27 PM    


Hello,

I've created a separate ticket on your behalf (T455126: The approach from T156289 works incorrectly). It has been placed in our processing queue and will be answered shortly.

Thanks,
Andrey

How to: show the Crosshair Cursor programmatically

$
0
0
This example demonstrates how to show the Crosshair Cursor programmatically on a mouse click.

How to: show the Crosshair Cursor programmatically

$
0
0
This example demonstrates how to show the Crosshair Cursor programmatically on a mouse click.

How to colorize a surface in stripes

$
0
0
This example demonstrates how to colorize a surface in stripes.

How to display column values within an expandable detail row

$
0
0

A data source may have many columns. Rather than creating a wide grid, you may wish to display some of these columns under the main data row, in an expandable area. The DetailRow template is well suited for this task. This example demonstrates how to place a PageControl within the DetailRow, and bind labels on it, to the data columns of the grid's data source.

Question Comments

Added By: Alexander Kennedy at: 12/23/2016 8:01:26 AM    Why do you not put screen shots with examples?Added By: Lanette (DevExpress Support) at: 12/23/2016 12:50:03 PM    

Hello,

I'm afraid that currently it's not clear what screen shots you mean. Would you please clarify this and describe it in greater detail? If you need to see how this example works, you can run it online and try this scenario. See the Run Online button on the right panel which allows you to run this example.


How to colorize series point markers in different colors

$
0
0
This example demonstrates how to color each point marker in a different color.

How to generate bands based on a collection in GridControl

$
0
0

The following sample demonstrates how to generate bands from a collection in a ViewModel.

ASPxSpreadsheet - How to handle cell value changes

$
0
0

Starting with version 16.2, ASPxSpreadsheet provides a functionality to handle cell value changes. Use the static ASPxSpreadsheet.CellValueChanged event for this purpose. Please note, this event handles cell value changes at the application level and it is raised for all documents opened within all instances of the ASPxSpreadsheet control. This way, the page hierarchy is not recreated and values of other controls located on the page are not available in this event handler.

See also: The "Spreadsheet - API - CellValueChanged Event" demo

How to create custom diagram containers and register them in the toolbox and ribbon gallery

$
0
0

In this example, we show how to create containers with custom headers and padding. 
DiagramControl supports a special language for defining containers. The root element that contains a container description is ContainerShapeTemplate. This element describes a container contour and may contain several segments:
Start. Specifies the start point
Line. Defines a line with start and end points
Arc. Defines an arc with start and end points

To define a container's header editor position, use the EditorBounds property. To specify a padding, set the ActualPadding property.
To register custom containers in the ribbon gallery, use the DiagramContainerGalleryRegistrator.RegisterContainerShapes method.

How to create custom diagram containers and register them in the toolbox and ribbon gallery

$
0
0
In this example, we show how to create containers with custom headers and padding. 
DiagramControl supports a special language for defining containers. The root element that contains a container description is ContainerShapeTemplate. This element describes a container contour and may contain several segments:
Start. Specifies the start point
Line. Defines a line with start and end points
Arc. Defines an arc with start and end points

To define a container's header editor position, use the EditorBounds property. To specify a padding, set the ActualPadding property.
To register custom containers in the ribbon gallery, use the DiagramContainerGalleryRegistrator.RegisterContainerShapes method.
Viewing all 7205 articles
Browse latest View live


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