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

How to implement the IncrementalBackColor and IncrementalForeColor properties

$
0
0

When a user performs an incremental search within the XtraGrid, the colors used to highlight the matching text are obtained from the current skin. It's possible to create your own skin and provide your own background and foreground colors. If you don't want to create a new skin, you can accomplish this task by creating a descendant to the existing in-place editor and introducing properties allowing you to manually specify these colors. Then create a descendant of the corresponding ViewInfo class and override the GetSystemColor method.


How to disable the label-click action for CheckedListBoxControl

$
0
0
By default, the CheckedListBoxControl component allows changing an item's state by clicking any part of the item. In this example, we demonstrate how to create a custom control inherited from CheckedListBoxControl and add the UseWholeItemToChangeCheckedStateByMouse option, which specifies the desired behavior.

Note: This example uses internal API and the provided approach is not a best practice. The implementation is provided only for the single selection mode.
Question Comments

Added By: Scott Wylie at: 7/16/2015 11:44:52 AM    

This code prevents the user from using the spacebar to toggle the checkbox.  How should this be changed to include this functionality and ONLY click the glyph to check using the mouse?

Added By: Alexey Z (DevExpress Support) at: 7/16/2015 10:21:43 PM    Hello,

In order to better serve and track multiple questions in your inquiry, we have taken the liberty of separating the issues you faced. Please refer to the CheckedListBoxControl - Check an item using only check box ticket for further correspondence.

(Obsolete) How to synchronize XtraGrid with CurrencyMangaer in Server Mode

$
0
0

XtraGrid automatically synchronizes its focused row index and the CurrencyManager.Position property. However, the BindingContext does not create the CurrencyManager for Server Mode components (EntityServerModeSource, XPServerCollectionSourceLinqServerModeSource, etc.), because they are not collections.

This example demonstrates how to work around this limitation. Binding to the focused row data is performed through a custom collection component that implements all interfaces necessary to support the WinForms data binding engine. This component uses GridView events to update the CurrencyManager position and obtain data items.

The custom component allows you to bind editors to data at design time. This example uses the ServerModeGridProjects database created by the Grid Server Mode demo application shipped with our components.

Question Comments

Added By: Chris D at: 6/9/2015 11:50:15 AM    

I tried and tried and tried but this is not working. As soon as i add the ServerModeBindingcomponent to my form (grid with XPServersource) I can´t even connect the Xtraeditors,memoedit (editvalue). I receive an This method is not supported), please advise :-(

Added By: Uriah (DevExpress Support) at: 6/10/2015 1:37:08 AM    

Hello Chris,

To process your recent post more efficiently, I created a separate ticket on your behalf: T253541: Component from E3125 example throws the NotSupportedException when placed on the design suface. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to hide Close Button of the Panel Container depending on the selected DockPanel

How to implement the in-place PopupContainerEdit with the dynamic popup content

$
0
0

To accomplish this task, create a separate UserControl for each pop-up window and provide necessary functionality to bind its editors to data and retrieve EditValue. Within the QueryPopup event of the RepositoryItemPopupContainerEdit, you can dynamically add necessary UserControl to the PopupContainerControl.

Web Dashboard - How to create the HTML5 JavaScript Web Dashboard application

How to hide non-working days in the Day view using custom commands and key handlers

$
0
0
This example demonstrates how to restrict the Day View navigation to display seven days, Saturday and Sunday excluded.
To accomplish this, the project implements a custom KeyToCommand behavior to handle the left and right arrow keys. Navigation commands execute custom methods defined in ViewModel. Commands are replaced with methods using the SchedulerControl.Commands property and DXCommand binding introduced in the DevExpress MVVM Framework .
A custom set of days is assigned to the DevExpress.Xpf.Scheduling.DayView.Days property.
The project handles the SchedulerControl.VisibleIntervalsChanged event to adjust visible dates if a view's visible intervals are changed with a method other than the navigation commands.





How to Show different views for the same object, based on the source view

$
0
0

Scenario:
I have two business classes representing a producer and a consumer of an transaction, and a transaction class that have references to both producer and consumer. I want to be able to open (or create) a transaction from the producer's transactions list, and do not show the producer property in the detail view (it is obvious). The same behavior I want for the consumer object.

Solution:
To accomplish the task, create additional detail views for the transaction class, with a different layout for each case (Transaction_DetailView_FromConsumer and Transaction_DetailView_FromProducer). Then, customize the nested list view models (Consumer_Transactions_ListView and Producer_Transactions_ListView) by specifying the custom detail view in the IModelListView.DetailView property.

See Also:
How to provide a specific View layout for users of certain security roles
Core - Provide an easy way to specify a different DetailView depending on whether a new object is created, shown from the ListView or on other conditions


How to implement IHierarchicalDataSource to show an XPO object hierarchy in ASPxTreeView

How to customize WebLayoutManager to avoid large gaps between the editor and its caption

$
0
0
Scenario:

When you have properties in your business class with captions of significantly different lengths, the detail view often looks awkward on the web. This happens because the built-in WebLayoutManager is relatively simple and doesn't support many layout properties that the WinLayoutManager supports (because of the underlying powerful XtraLayout control). Specifically, the item caption length of layout items on the web is calculated as a maximum of all visible items on the detail view. As a result, we have too large a gap between a short caption and the editor when there are long captions.



Solution:

This example demonstrates a possible solution to this common issue by introducing additional properties in the layout group and layout item model nodes.

We create a new model interface that extends the IModelLayoutGroup interface (similar to IModelWinLayoutGroup) with the additional TextAlignMode property. Another model interface extends the IModelLayoutViewItem interface (similar to IModelWinLayoutItem) in the same manner. These properties allow you specify different modes of the caption width calculation for individual items and items in each group separately. Refer to the TextAlignModeGroup and TextAlignModeItem enumerations documentation for options description. These new model interfaces are registered in the web module.

We create a custom layout manager derived from the WebLayoutManager class with the LayoutItem method overridden. In this method, the CaptionWidth is calculated according to new options specified in the item and parent groups it belongs to. The custom layout manager is instantiated in the overridden CreateLayoutManagerCore method of the WebApplication.

Now, the detail view layout can be fine tuned via the Model Editor in the web module in a similar manner as you would in the WinForms application model.


Note how some caption widths are set to local minimums, some set to a a common minimum calculated in the owner or outer group and some widths are calculated globally.

See also:
Extend and Customize the Application Model in Code

 

Question Comments

Added By: Massimo Endrighi 1 at: 1/13/2016 11:31:49 AM    

Could you integrate this functionality in the framework at platform-independent  level ?
The benefits will be:
- the platform independent layout designer will be more WYSIWYG
- there will be no more the need to customize web an windows in the same way.

Added By: Michael (DevExpress Support) at: 1/14/2016 1:01:53 AM    @Massimo: Thanks for your feedback. We already have this task in our wish list: Layout.Web - Support more attributes and features for detail form layout ASP.NET applications.

OBSOLETE - How to extend the security strategy to provide object access control, based on encrypted license data

$
0
0

Although you can create a new security strategy from scratch, here we'll extend the SecuritySimple strategy.
First, create an interface to declare the user's license.


[C#]
publicinterfaceILicensedUser:ISimpleUser{stringLicense{get;}}

Then, create a custom user class and implement this interface, or extend the existing SimpleUser class.
Now, create a SecuritySimple descendant, and override the ReloadPermissions method to assign permissions, based on license data.

[C#]
protectedoverridePermissionSetReloadPermissions(){PermissionSetset=base.ReloadPermissions();if(this.User.IsActive){base.IsGrantedForNonExistentPermission=true;set.AddPermission(newObjectAccessPermission(typeof(object),ObjectAccess.AllAccess));set.AddPermission(newObjectAccessPermission(typeof(IPropertyBag),ObjectAccess.AllAccess));set.AddPermission(newObjectAccessPermission(typeof(IXPSimpleObject),ObjectAccess.NoAccess));set.AddPermission(newObjectAccessPermission(this.UserType,ObjectAccess.AllAccess));set.AddPermission(newEditModelPermission(this.User.IsAdministrator?ModelAccessModifier.Allow:ModelAccessModifier.Deny));if(!this.User.IsAdministrator){set.AddPermission(newObjectAccessPermission(this.UserType,ObjectAccess.ChangeAccess,ObjectAccessModifier.Deny));if(!this.AllowNonAdministratorNavigateToUsers){set.AddPermission(newObjectAccessPermission(this.UserType,ObjectAccess.Navigate,ObjectAccessModifier.Deny));}}ILicensedUserluser=this.UserasILicensedUser;if(luser!=null&&!string.IsNullOrEmpty(luser.License)){AddLicensedPermissions(set,DecryptLicense(luser.License));}returnset;}base.IsGrantedForNonExistentPermission=false;returnset;}privatevoidAddLicensedPermissions(PermissionSetset,stringlicense){if(license==null)return;string[]items=license.Split(';');foreach(stringiteminitems){Typetype=Type.GetType(item);if(type!=null){ObjectAccessPermissionp=newObjectAccessPermission(type,ObjectAccess.AllAccess);set.AddPermission(p);}}}

Here we implement additive permissions, based on the list of classes encoded in the license. This part can be implemented in different ways, including subtractive permissions, or any other complex scheme. You should additionally implement the DecryptLicense method according to your security requirements.
To use this security strategy, open the WinApplication or WebApplication module, and replace the existing security strategy with this one. Then, set the SecuritySimpleEx.UserType property to your new user class, and add some authentication type.

How to show a large image in a popup when a small image in a list view column is clicked

$
0
0

By default, XAF opens a detail view in response to a double-click in a list view row. This behavior can be changed by handling the ListViewProcessCurrentObjectController.CustomProcessSelectedItem event. Since we want to show an image for double-clicks in Image type columns, we should determine the element under the click point using the GridHitInfo object.

XRRichText - How to make a page break from RTF contents to be inserted into XtraReport

$
0
0

XtraReports have their own page breaking mechanism, which is based on the page content. You can resolve this problem by splitting the RTF content into several blocks based on the PageBreak character by using our RichEditDocumentServer.

This sample illustrates how it can be done

See also :
XRRichText - A page break in a RTF contents should lead to a page break in a report

Question Comments

Added By: Patrick Miller at: 2/22/2018 11:39:33 AM    This is really nice, I doubt this is possible but let's say you are using this method and you have a number lists that continues into the next page. This method listed here, the number lists get's reset in the next page. Back to 1. You can try it by opening the sample fish.rtf that is in this example, do a number lists that continues into the next page and you will see.

I kinda doubt there is anyway to fix this as we are selecting each page, we are loosing some of the original rtf header stuff from the last page.

Thanks again for the great sample.

Pat

BootstrapChart - How to bind to filtered or sorted ASPxGridView data on the server side at runtime

$
0
0
This example demonstrates how to show filtered or sorted ASPxGridView data in BootstrapChart on a callback at runtime by using server side data binding.

In page markup, enable ASPxGridView’s ShowFilterRow property to show FilterRow in it. Handle the DataBound event on the first page load to bind BootstrapChart data to ASPxGridView data. Use the VisibleRowCount property to determine what ASPxGridView data is not filtered. Set the ValueType property of the ValueAxisCollection.BootstrapChartValueAxis settings to enable sorting of against BootstrapChart's ValueAxis values.

Handle the ASPxClientGridView.BeginCallback event to save the callback command name in the javascript variable. Then handle ASPxClientGridView's EndCallback to check the callback command name and perform a callback if the condition is satisfied (the command name is "APPLYCOLUMNFILTER" or "SORT").

Put the BootstrapChart to ASPxCallbackPanel to update its data source on the server side after a callback. Then, handle ASPxCallbackPanel's Callback event to get the filtered or sorted ASPxGridView data, convert it to BootstrapChart's data format and bind to BootstrapChart on the server side on a callback.

BootstrapChart - How to bind to filtered or sorted ASPxGridView data on the client side at runtime

$
0
0

This example demonstrates how to show filtered or sorted ASPxGridView data in BootstrapChart on a callback at runtime by using client side data binding.

In page markup, enable ASPxGridView’s ShowFilterRow property to show FilterRow in it. Handle the DataBound event on the first page loading to bind BootstrapChart data to ASPxGridView data.
Use the VisibleRowCount property to determine what ASPxGridView data is not filtered.

Then, handle ASPxGridView's AfterPerformCallback event to get filtered or sorted ASPxGridView's data and convert it to BootstrapChart's data format on the server side after a callback. In this event handler, check the e.CallbackName property to determine the sorting ("APPLYCOLUMNFILTER") or filtering ("SORT") callback command. Convert BootstrapChart data into the JSON format using the JavaScriptSerializer.Serialize function. Set the obtained JSON data string as ASPxGridView JSProperties to transfer data from the server to the client.

Handle ASPxGridView's client-side EndCallback event for client-side data binding on a callback initiated by data filtering or sorting. Call the JSON.parse function to obtain transferred ASPxGridView data as a JavaScript object.

To set BootstrapChart's data source on the client side, use BootstrapChart’s private BootstrapClientChart.SetDataSource method.


ASPxTreeList - How to have one focused node among ASPxTreeLists placed in an ASPxGridView detail row

$
0
0

This example demonstrates how to have one focused node within several ASPxTreeLists located in an ASPxGridView detail row template.

Add the detailTreeLists JavaScript dictionary to store the ASPxTreeLists currently displayed in ASPxGridView.

[JavaScript]
detailTreeLists = {};

Add the GetAllFocusedTreeListsOnPage JavaScript function to get all focused ASPxTreeLists within ASPxGridView. After that, add the ValidateFocusedNode JavaScript function to check if a node has been focused in every displayed ASPxTreeList. If so, the ASPxClientTreeList.SetFocusedNodeKey method call will reset the ASPxTreeList focused node.

[JavaScript]
function GetAllFocusedTreeListsOnPage(){var result = [];for(var treeListName in detailTreeLists){var treeList = detailTreeLists[treeListName];var focusedNodeKey = treeList.GetFocusedNodeKey();if(!treeList.GetMainElement() || focusedNodeKey === null || focusedNodeKey === "")continue; result.push(treeList);}return result;}function ValidateFocusedNode(treeList){var focusedControls = GetAllFocusedTreeListsOnPage();if(focusedControls.length > 1 && focusedControls.indexOf(treeList)> -1) treeList.SetFocusedNodeKey(null);}

Assign the onTreeListInit function as the ASPxClientTreeList.Init event handler to add newly displayed ASPxTreeLists into detailTreeLists and call the ValidateFocusedNode function. In addition, assign the onTreeListEndCallback function as the ASPxClientTreeList.EndCallback event handler and call ValidateFocusedNode.

[JavaScript]
function onTreeListInit(s, e){ detailTreeLists[s.name] = s; ValidateFocusedNode(s);}function onTreeListEndCallback(s, e){ ValidateFocusedNode(s);}

To reset the focused node in ASPxTreeLists which are not currently focused by the user, assign the onTreeListFocusedNodeChanged function as the ASPxClientTreeList.FocusedNodeChanged event handler.

[JavaScript]
function onTreeListFocusedNodeChanged(s, e){var focusedControls = GetAllFocusedTreeListsOnPage();for(var i = 0; i < focusedControls.length; i++){var control = focusedControls[i];if(control !== s) control.SetFocusedNodeKey(null);}}

Add the removeOutdatedTreeLists JavaScript function to remove the ASPxTreeLists which are not currently displayed from detailTreeLists. After that, call removeOutdatedTreeLists in the onGridEndCallback handler of the ASPxClientGridView.EndCallback event.

[JavaScript]
function removeOutdatedTreeLists(){var treeListsForRemoving = [];for(var treeListName in detailTreeLists){var treeList = detailTreeLists[treeListName];if(!treeList.GetMainElement()) treeListsForRemoving.push(treeListName);}for(var i = 0; i < treeListsForRemoving.length; i++)delete detailTreeLists[treeListsForRemoving[i]];}function onGridEndCallback(s, e){ removeOutdatedTreeLists();}

How to use the HTML5 Document Viewer in a DevExtreme application

$
0
0

This example illustrates how to integrate the HTML5 Document Viewer into a DevExtreme-based Single Page Application project.
 
This example consists of two projects.
1. Frontend - a DevExtreme project that includes all necessary styles, scripts and HTML-templates required by the Document Viewer.
2. Backend - an ASP.NET MVC 5 application. At the backend, cross-domain requests are enabled (Access-Control-Allow-Origin) and a custom report storage is implemented.

For a step-by-step tutorial, refer to the following document: Document Viewer Integration into a DevExtreme application.

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.

See also:
How to use the Web Report Designer within a DevExtreme application

Question Comments

Added By: Lisa Agnes 1 at: 10/19/2017 7:07:02 PM    can this code example be used if i am using DevExtreme - MVC .NET Core 2.0 with EF Core ?
Added By: Vasily (DevExpress Support) at: 10/20/2017 12:46:55 AM    Hi Lisa,

I see that you already created a separate thread for this question: T567004: Is it possible to use DevExreme integration approach in a .NET Core application. So, let's continue our conversation in that thread to avoid discussing the same topic in multiple threads.Added By: Lee Meng at: 2/26/2018 1:07:15 AM    Hi,

Bower is deprecated. Could you please give guide without using bower?
Where to download JS lib?

How to obtain a checked value for a check box

$
0
0
This example shows how to get a checked value for the "Female" check box and check the check box with this value. 

To accomplish this task, call the GetCheckboxCheckedValue  method using a PdfDocumentProcessor instance and the field name.

To obtain interactive form data, call the PdfDocumentProcessor.GetFormData method. To check the "Female" check box, use the PdfFormData.Value property.

How to reorder grid rows by drag and drop

$
0
0

This example extends the example provided in the How to allow an end-user to move the rows in a grid up and down if the grid is bound to a DataTable article and illustrates how to reorder rows by drag and drop.

Starting with version 17.2.4, you can attach Drag And Drop Behavior to GridControl to implement reordering. For this, handle the DragOver and DragDrop events of the corresponding behavior using the following code:

[C#]
DragDropBehaviorgridControlBehavior=behaviorManager1.GetBehavior<DragDropBehavior>(gridView);gridControlBehavior.DragDrop+=Behavior_DragDrop;gridControlBehavior.DragOver+=Behavior_DragOver;

 

[VB.NET]
Dim gridControlBehavior As DragDropBehavior = behaviorManager1.GetBehavior(Of DragDropBehavior)(Me.gridView1)AddHandler gridControlBehavior.DragDrop, AddressOf Behavior_DragDropAddHandler gridControlBehavior.DragOver, AddressOf Behavior_DragOver

In the DragOver event handler, calculate drag-drop parameters (InsertType, InsertIndicatorLocation, Action and Cursor) using the static DragOverGridEventArgs.GetDragOverGridEventArgs method:

[C#]
privatevoidBehavior_DragOver(objectsender,DragOverEventArgse){DragOverGridEventArgsargs=DragOverGridEventArgs.GetDragOverGridEventArgs(e);e.InsertType=args.InsertType;e.InsertIndicatorLocation=args.InsertIndicatorLocation;e.Action=args.Action;Cursor.Current=args.Cursor;args.Handled=true;}
[VB.NET]
PrivateSub Behavior_DragOver(ByVal sender AsObject, ByVal e As DragOverEventArgs)Dim args As DragOverGridEventArgs = DragOverGridEventArgs.GetDragOverGridEventArgs(e) e.InsertType = args.InsertType e.InsertIndicatorLocation = args.InsertIndicatorLocation e.Action = args.Action Cursor.Current = args.Cursor args.Handled = TrueEndSub

Data Source reordering logic should be implemented in the DragDrop event handler.

In older versions, reordering is implemented using the standard Drag events.

Question Comments

Added By: Micha Ben-Efraim at: 6/11/2012 2:11:54 AM    

I copied this example for reordering the element of a list bound to the control and it works almost perfectly. The problem is that the control doesn't scroll during D&D: the list is longer as the displayed window. If I select the first or the last item in the list (first/last row) and want o move to the last/first position, which is not visible, the view should scroll somehow in order to show the target drop row. But it doesn't do it when I move the cursor to the top/bottom of the view.
Can it

Added By: Fmonteiro at: 11/5/2013 3:34:26 AM    

Is possible to make this with the AdvBandedGridView?
I've tryed to make the same but in the:
Private Sub GridControl1_DragOver(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles GridControl1.DragOver
    ' If e.Data.GetDataPresent(GetType(GridHitInfo))

allways returns False, so never enters the IF.

Added By: softwaresupport@smec.com softwaresupport@smec.com at: 6/4/2014 5:43:37 AM    

Hi created a new ticket for this implementation as i dont find that it works

Added By: softwaresupport@smec.com softwaresupport@smec.com at: 6/4/2014 5:44:03 AM    

Here is the ticket ID : T114366

Added By: Nikita (DevExpress Support) at: 6/4/2014 11:29:33 PM    

Hello,
Ok, let's continue our discussion in this ticket.

Added By: Miles Young at: 2/6/2015 7:34:33 AM    

Hi,

This works fine for me after I changed my "Order" column to decimal in my database.

I'd like to know how to change this value and make sure that RowUpdated() is fired though, like when I edit a row normally.

Thanks for this example.

M.Young

Added By: Svetlana (DevExpress Support) at: 2/6/2015 9:25:03 AM    Hi, 

We are already working on your inquiry in the How to force row update thread you created. We will answer you there. Please do not create duplicate posts. Thank you for your understanding. Added By: Dharmesh Jajal 1 at: 10/1/2015 3:53:16 PM    

Please post a solution if the datasource is not a datatable or dataset and is List<SomeRecord>.

Added By: Alisher (DevExpress Support) at: 10/2/2015 12:41:39 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T296044: Please post a solution if the datasource is not a datatable or dataset and is List<SomeRecord>. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Stefan R at: 2/28/2018 12:22:08 AM    Hello,
can you please please post a solution if the Datasource is a BindingSource?
(i use a mdb file as database)
thx Stefan

How to customize the TimeRuler using styles and templates

Viewing all 7205 articles
Browse latest View live


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