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

How to: Bind TileBar to a Collection of Items

$
0
0

To use TileBar according to the MVVM pattern, you can generate TileBarItems from a collection. To accomplish this task, assign a collection to the TileBar.ItemsSource property.

To change properties of generated TileBarItems, use the TileBar.ItemContainerStyle property.

If you want to build a multi-level hierarchy, put the TileBar into TileBarItem.FlyoutContentTemplate.


GridView - How to display a Group Summary in group headers

ASPxGridView - How to display a Group Summary in group headers

How to: Configure the Way Properties Are Displayed and Edited at the Data Model Level

$
0
0

The DXPropertyGrid supports a large number of attributes from the System.ComponentModel.DataAnnotations library as well DevExpress attributes (see Data Annotation Attributes for more information), and you can use them to control the way properties are displayed.

In this example, we used several attributes including the PropertyGridEditorAttribute, which allows you to specify a particular editor for a property in the PropertyGridControl.

How to resize columns by dragging vertical lines in cells when column headers are hidden

$
0
0

By default, columns can be resized only using column headers. However, when column headers are hidden (DataViewBase.ShowColumnHeaders is false), they cannot be used for resizing. To change column width in this scenario, the DXThumb element can be used. Create a DXThumb descendant and implement the IColumnPropertyOwner interface. Then, use this descendant in the CellTemplate.

 

Note
In optimized mode (version v14.1 and higher), a non-optimized editor (TextEdit) can be replaced with a lightweight editor (InplaceBaseEdit) as demonstrated below.

[XAML]
<grd:TableView.CellTemplate><DataTemplate><DockPanelLastChildFill="True"> ...<dxe:InplaceBaseEditName="PART_Editor"/></DockPanel></DataTemplate></grd:TableView.CellTemplate>

 

See Optimized Mode Styles and Templates for more information.

How to implement an event to customize a filter string produced by the SearchLookUpEdit

$
0
0

-------------------------------------------------------------------
In 19.1 we've implemented two new options that specify how our Find Panel works:
1) ParserKind  - If a search string contains whitespaces, the control splits it into separate logical blocks. This option specifies how these blocks are combined into a search query.
2) Filter Condition - Use the Condition property to specify the search operator (ContainsStartsWithEqualsLike).
So starting with 19.1 you can use these options to manage the Find Panel behavior without using descendants. 
In case of using SearchLookUpEdit you can find these options in the SearchLookUpEdit .Properties.PopupView.OptionsFind section.

See also:
 WinForms - Data Grid - New Find Panel Options.
-------------------------------------------------------------------

Sometimes it is useful to adjust a string entered in the Find Panel based upon any rules and filter data correspondingly. For instance, if an end-user enters one two in the Find Panel data search will be performed according to whether or not either one or two string is contained in any search column. To search data against whole "one two" string it is necessary to enclose the filter string in quotes (please review the Find Panel help article to learn all capabilities of the Find Panel). To make this behavior default you can add the quotes to the filter string manually by handling the SearchLookUpEdit.UpdateDisplayFilter event.

This examples illustrates how to implement the SearchLookUpEdit.UpdateDisplayFilter event.

Question Comments

Added By: Carlos90210 at: 6/5/2013 11:17:30 AM    

Excellent solution, especially when running in server mode. Why this event is not included as default? it is almost impossible to catch events with linq in server mode.

Added By: Keith Palihakkara at: 7/10/2013 1:00:41 AM    

I can't seem to find this event on the SearchLookUpEdit in 13.1.5, has it been replaced?

BootstrapGridView - Batch Edit mode - How to edit CheckBox column in a single click

$
0
0

Starting with v17.1.4 and v17.2.3, the BootstrapGridView control supports this functionality out of the box. To get the desired behavior, enable the AlwaysShowCheckboxesInCheckColumns property:

[ASPx]
<SettingsEditing><BatchEditSettingsAlwaysShowCheckboxesInCheckColumns="true"/></SettingsEditing>


To implement this behavior in old versions, switch to the 17.1.3+ branch.

OBSOLETE - How to suppress the save confirmation when closing a new unmodified object DetailView

$
0
0

Scenario
This example demonstrates how to implement the following behavior (which is default in Microsoft Outlook) in XAF Windows Forms applications:

- A user can create a new record, and when its detail form is opened he or she may close the form without entering any data (e.g., a new record was created by accident). In this case, the form can be closed without any save confirmation, because no user data needs to be saved.

- If a user enters some data into the form and then closes it, the save confirmation appears as expected not to lose entered data.
To test it, run functional tests from the E2114.EasyTests\E2114.ets folder.

 

Steps to implement
Copy the WinSolution.Module.Win\SuppressConfirmationForNewObjectsDetailViewController.xx file into YourSolutionName.Module.Win project.


Your feedback is needed!
We are hesitating to include the current implementation by default, because there are many ways to instantiate new objects in Views and it many cases it is difficult to uniquely state that an object is "untouched". For instance, you may have custom initialization code in the AfterConstruction or OnActivated methods of your business class or Controller, in the ObjectCreating, CustomCloneObject, ActionBase's Execute or other event handlers of standard and custom XAF UI entities.
You and other readers can help us decide faster if you share your thoughts on whether this logic should cover any internal programmatic changes to objects (including Actions!) or should only consider a user touching data editors by hand. Thanks in advance. 

See Also:
WinModificationsController Class
ModificationsController.ModificationsHandlingMode
Core - Disable the confirmation dialog when closing a form with a new object left untouched

Question Comments

Added By: rushdan . at: 12/4/2014 2:08:46 AM    

I have see example . That is great.
So I would like to ask, is it possible to apply for Web ?

Thanks

Added By: Dennis (DevExpress Support) at: 12/4/2014 2:40:43 AM    @rushdan: This solution cannot be applied to the Web version because there are no such confirmation dialogs there by default.Added By: Paul Kubb at: 3/31/2016 9:04:33 PM    Just a little comment that I think this feature should be out-of-the-box.
Popping out this message every time even nothing touched is annoying and I don't think anybody will like it.Added By: Dennis (DevExpress Support) at: 4/1/2016 2:19:57 AM    @Paul: Our team will take your feedback into account, thanks.Added By: Alex Miller at: 4/1/2016 4:22:05 AM    I totally agree with Paul.
@Dennis Please +1 :) Added By: Dennis (DevExpress Support) at: 4/1/2016 6:10:00 AM    OK, thanksAdded By: Willem de Vries at: 1/4/2018 1:05:00 AM    What if this was default behavior?Added By: Dennis (DevExpress Support) at: 1/4/2018 3:47:51 AM    

@Willem: Thank you for your suggestion and please let us know whether this simple solution meets your business needs.
We are hesitating to include the current implementation by default, because there are many ways to instantiate new objects in Views and it many cases it is difficult to uniquely state that an object is "untouched". For instance, you may have custom initialization code in the AfterConstruction or OnActivated methods of your business class or Controller, in the ObjectCreating, CustomCloneObject, ActionBase's Execute or other event handlers of standard and custom XAF UI entities.

You and other readers can help us decide faster if you share your thoughts on whether this logic should cover any internal programmatic changes to objects (including Actions!) or should only consider a user touching data editors by hand. Thanks in advance.

Added By: Willem de Vries at: 1/4/2018 7:11:39 AM    Hi Dennis,

I understand your hesitations and want to withdraw my earliers suggestion.

You could leave it to the developer by introducing a class decorator [SuppressConfirmationForNewObjects] or something alike. That way the developer can apply this logic by choice and on a much more precise scale.

Willem Added By: Dennis (DevExpress Support) at: 1/4/2018 8:25:15 AM    

Thanks for your update, Willem - we will take your idea into account and continue monitoring user requirements in this regard. Right away, you can code such a custom attribute along with a Controller looking at it. Here are additional documentation links that should help you enhance the original example further:
Concepts > Business Model Design > Types Info Subsystem > Access Business Object's Metadata
Extend and Customize the Application Model in Code
https://docs.microsoft.com/en-us/dotnet/standard/attributes/writing-custom-attributes


How to configure the SQL Data Source component in code to bind the GridControl to a database

GridView - BindToLINQ - How to export a large amount of filtered data with Reports

$
0
0

At present our MVCxGridView export mechanism has some limitations: it is impossible to export a lot of filtered data, because the mechanism requests all data from a database and then filters it. Thus, a request can be fulfilled, and the 'System.OutOfMemoryException' exception occurs. As a solution, request filtered data yourself and export it using the XtraReports Suite. This example demonstrates how you can do this using LINQ-to-SQL.

To pass the FilterExpression to a Controller's Action, obtain and save it to GridView CustomJSProperties in CustomJSProperties:


[C#]
settings.CustomJSProperties=(s,e)=>{MVCxGridViewgridView=(MVCxGridView)s;e.Properties["cpGridFilterExpression"]=gridView.FilterExpression;};

 

[VB.NET]
settings.CustomJSProperties = Sub(s, e) Dim gridView = TryCast(s, MVCxGridView) e.Properties("cpGridFilterExpression") = gridView.FilterExpression EndSub


When a user clicks the Export data, take the filter expression from GridView CustomJSProperties and add it to the collection of jQuery selector parameters.

[JavaScript]
function onClick(s, e){var actionParams = $("form").attr("action").split("?filterString="); actionParams[1] = encodeURIComponent(GridView.cpGridFilterExpression); $("form").attr("action", actionParams.join("?filterString="));}


The XtraReport class instance that's used in this Code Example is added as described in the Lesson 1 - Create a Static Report in ASP.NET MVC tutorial. The report controls are bound to data using the Embedded Fields (Mail Merge) feature.

You can learn more about approaches used in this example in the following resources:

How to: Create a Table Report
How to create a web based report at runtime
How to convert the CriteriaOperator to a lambda expression, so, the latter expression can be used in the IQueriable source

GridView Extension - Provide the capability to export large LINQ data

Question Comments

Added By: Kevin Turpin 1 at: 2/10/2016 11:50:47 AM    OK, i absolutely love that i can do this, nicely done.Added By: John John Smith at: 3/23/2016 9:39:34 AM    There really isn't any difference between binding to an XtraReport just to export, and using a datatable is there?  The code in the home controller looks almost identical.

It doesn't matter how I filter my data, if it goes above the .Net 2gb limit then it throw the out of memory exception error.Added By: Vladimir Frizen (DevExpress) at: 3/23/2016 12:59:31 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T359906: The out of memory exception occurs when GridVIew data in being exported. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Gustavo Paradiso at: 12/19/2016 3:22:05 PM    Hi,
i'm trying to apply this aproach with MVCExtensions. I filter my grid using SearchPanel and everytime the grid does the callback ((MVCxGridView)s).FilterExpression returns an empty string.

 settings.CustomJSProperties = (s, e) =>
    {
        MVCxGridView gr = (MVCxGridView)s;
        e.Properties["cpGridFilterExpression"] = gr.FilterExpression; // FilterExpression always returns ""
    };

Does it work for MVC? Added By: Nataly (DevExpress Support) at: 12/19/2016 10:22:57 PM    

Hello,

I've created a separate ticket on your behalf (T464479: GridView - How to export data filtered by Search Panel). It has been placed in our processing queue and will be answered shortly.

How to export a cell range to a DataTable

$
0
0

This example illustrates how you can export a cell range to a System.Data.DataTable object.

The following steps are required:

1) Add a reference to the DevExpress.Docs.dll assembly to your Spreadsheet project. The distribution of this assembly requires a license to the DevExpress Office File API or DevExpress Universal Subscription.
2) Use the DevExpress.Spreadsheet.Worksheet.CreateDataTableExporter method to create a DevExpress.Spreadsheet.Export.DataTableExporter instance.
3) Call the DataTableExporter's Export method.

You can use the Worksheet.CreateDataTable method to create an empty DataTable from a cell range. This method obtains column names from the range headings, and determines the column data types based on the first row of the specified range.

Question Comments

Added By: Juan Capiau - D at: 7/29/2014 6:55:38 AM    

I'm trying this example and the 'Export Worksheet Table Using Exporter Options' throws an error (Index was out of range) on Sub barButtonItemUseExporterOptions_ItemClick, line 'Dim range As Range = worksheet.Tables(0).Range'. i've tried multiple files, none work. If i select a range and export that (the 'Export Selected Range to Data Table') there is no problem. How can I fix this ?

System.ArgumentOutOfRangeException was unhandled
 HResult=-2146233086
 Message=Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
 ParamName=index
 Source=mscorlib
 StackTrace:
      at System.ThrowHelper.ThrowArgumentOutOfRangeException()
      at DevExpress.XtraSpreadsheet.API.Native.Implementation.NativeCollectionBase`3.get_Item(Int32 index)
      at ExportToDataTableExample.Form1.barButtonItemUseExporterOptions_ItemClick(Object sender, ItemClickEventArgs e) in C:\Users\JCA\Documents\Samples\XtraSpreadSheet\14.1.5\E4997\ExportToDataTableExample\ExportToDataTableExample\Form1.vb:line 68
      at DevExpress.XtraBars.BarItem.OnClick(BarItemLink link)
      at DevExpress.XtraBars.BarBaseButtonItem.OnClick(BarItemLink link)
      at DevExpress.XtraBars.BarButtonItem.OnClick(BarItemLink link)
      at DevExpress.XtraBars.BarItemLink.OnLinkClick()
      at DevExpress.XtraBars.BarButtonItemLink.OnLinkClick()
      at DevExpress.XtraBars.BarItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
      at DevExpress.XtraBars.BarButtonItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
      at DevExpress.XtraBars.BarItemLink.OnLinkActionCore(BarLinkAction action, Object actionArgs)
      at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.ClickLink(BarItemLink link)
      at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.UnPressLink(BarItemLink link)
      at DevExpress.XtraBars.Ribbon.Handler.BaseRibbonHandler.OnUnPressItem(DXMouseEventArgs e, RibbonHitInfo hitInfo)
      at DevExpress.XtraBars.Ribbon.Handler.BaseRibbonHandler.OnUnPress(DXMouseEventArgs e, RibbonHitInfo hitInfo)
      at DevExpress.XtraBars.Ribbon.Handler.BaseRibbonHandler.OnMouseUp(DXMouseEventArgs e)
      at DevExpress.XtraBars.Ribbon.Handler.RibbonHandler.OnMouseUp(DXMouseEventArgs e)
      at DevExpress.XtraBars.Ribbon.RibbonControl.OnMouseUp(MouseEventArgs e)
      at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
      at System.Windows.Forms.Control.WndProc(Message& m)
      at DevExpress.Utils.Controls.ControlBase.WndProc(Message& m)
      at DevExpress.XtraBars.Ribbon.RibbonControl.WndProc(Message& m)
      at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
      at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
      at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
      at DevExpress.Utils.Win.Hook.ControlWndHook.CallWindowProc(IntPtr pPrevProc, IntPtr hWnd, Int32 message, IntPtr wParam, IntPtr lParam)
      at DevExpress.Utils.Win.Hook.ControlWndHook.WindowProc(IntPtr hWnd, Int32 message, IntPtr wParam, IntPtr lParam)
      at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
      at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
      at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
      at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
      at System.Windows.Forms.Application.Run(Form mainForm)
      at ExportToDataTableExample.Program.Main() in C:\Users\JCA\Documents\Samples\XtraSpreadSheet\14.1.5\E4997\ExportToDataTableExample\ExportToDataTableExample\Program.vb:line 45
      at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
      at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
      at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
      at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
      at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
      at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
      at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
      at System.Threading.ThreadHelper.ThreadStart()
 InnerException:

Added By: Brian (DevExpress) at: 7/29/2014 7:25:34 AM    Please make sure that the document loaded in the SpreadsheetControl has a table. If it does not, insert a table using the Insert Table command in the Insert ribbon group, or use the Spreadsheet API as described in the How to: Create a Table document.Added By: Juan Capiau - D at: 8/1/2014 7:04:15 AM    

Not sure we're talking about the same thing. there is also no 'insert table' command or an insert ribbon group. Either i'm missing something basic (which is entirely possible) or the example is not complete. i'd like to understand the functionality and since this is an example that is supposed to do just that.... if you can assist, i'd appreciate it.

Added By: Ted (DevExpress Support) at: 8/4/2014 12:53:39 AM    

Hello Juan, 

I have extracted your original message with an exception description to a separate ticket - T136499: ArgumentOutOfRangeException is raised in the E4997 example. Our team will address it as soon as possible. 

How to use CellStyle in different themes

$
0
0

Starting with v18.2CellStyle is theme-independent. Do not define its BasedOn property in v18.2 or greater. In previous versions, use the approach illustrated in this example.

To implement a cell style of GridControl, it is necessary to create a new style based on the already existing cell style. When an application theme is changed, the basic cell style must be also changed. To do this, you can create behavior that will change this basic style. It is necessary to add the ThemeManager's ThemeChanged event handler to the behavior.

How to create an ASPxGridView descendant class

$
0
0

This example shows a simple ASPxGridView descendant class. The CustomGridViewDesigner class supports design-time editing capabilities for the CustomGridView control.

Note that we always suggest our customers avoid creating descendants of our controls without a serious reason.
- Descendants have issues with themes - Why a theme / skin file is not applied to an ASP.NET control descendant?
- Due to a complex nature of ASPxGridView, its hierarchy of inner controls can be recreated multiple times. This should be taken into account during development.
- It's hard to properly rely on internal properties and fields without the source code and being able to debug incorrect behavior.

ASPxGridView - How to upload files in Edit mode and review them on a cell click in Browse mode

$
0
0

This example demonstrates how to implement a custom column with hyperlinks to different files. At first, links are empty. You can upload a file in Edit mode, and this row hyperlink will contain the URL to this file.

How to apply a custom theme to grid elements

$
0
0

 

We do not support this example starting from v.12.1. For versions prior to v.12.1, use the approach illustrated in other branches of this example.

In newer versions, you can create a custom theme by using a tool depending on your DX controls version:


- v.18.2 and newer
: use the WPF Theme Designer.

- v.12.1 - v.18.1: use the Theme Editor for WPF.


See also:
T361488 - How to find and change an inner DevExpress control template.

Question Comments

Added By: yelixz mcshame at: 11/19/2012 5:47:44 PM    

how can i change the color?.,, just change the code right?


How to use the ASPxSpreadsheet control in an XAF ASP.NET WebForms application

$
0
0

Scenario
I want to display my business object that has a byte array property as an Excel document allowing users to modify the content and save it to the database. ASPxSpreadsheet is an appropriate component for this task, but how to implement a Web Property Editor based on it?

Backgrounds
Unlike regular ASP.NET editors and controls, ASPxSpreadsheet is a front-end to a document service similar to Google Docs that will be running on your web site if you add this component to your application. Because of this, a property editor based on the ASPxSpreadsheet component has some specific features.

If a user opens a document, the next user who opens the same document will see the actual document content even if the first user did not save it to the database.


The Refresh action does not discard changes made in the document. The actual document state is stored in the service, and the content stored in the database is used as backup.


The Save action updates the content stored in the database. If the user closed a document without clicking the Save action, changes made to the document will be stored on the service and another user can save them to the database.


The property editor demonstrated in this example works with properties of a specific type - SpreadsheetDocument, and does not write any changes to a property. Instead, it modifies referenced objects directly. The SpreadsheetExample.Module\BusinessObjects\Report.cs (SpreadsheetExample.Module\BusinessObjects\Report.vb) file contains a class that has a property of the SpreadsheetDocument type. Note that this property is considered a part of the persistent object (that is why it has the Aggregated attribute) and automatically initialized with the value within the AfterConstruction method.

The editor implementation is simple. Refer to the SpreadsheetExample\SpreadsheetExample.Module.Web\Editors\SpreadsheetEditor.cs (SpreadsheetExample\SpreadsheetExample.Module.Web\Editors\SpreadsheetEditor.vb) file for details. It uses the ASPxSpreadsheet.Open and ASPxSpreadsheet.SaveCopy methods to synchronize the opened document with the database. Documents are identified by the persistent object's key property. This allows opening a separate document for each record in the database.

DxDataGrid for Blazor - How to show/hide columns based on certain properties

$
0
0

This example illustrates how to toggle DxDataGrid's column visibility using the Visible property.

DxDataGrid for Blazor - How to edit/delete the selected row by clicking on external buttons

$
0
0

This example illustrates how to start editing/delete the selected row in DxDataGrid programmatically.

DxDataGrid for Blazor - How to show a detail infromation in DxFormLayout

$
0
0

This example illustates how to create DxDataGrid for Blazor, add a template column with a button and show some detail information about the current record in DxFormLayout.

DxDataGrid for Blazor - How to implement the delete confirmation feature

$
0
0

This example illustrates how to implement the confirmation dialog before deleting a record

Viewing all 7205 articles
Browse latest View live


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