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

How to hide a BarEditItem's caption

$
0
0

This example shows how to hide a BarEditItem's caption even if the control is not empty.


In versions 2011 vol 2 and 2012 vol 1, this functionality can be implemented by overriding the {dxbt:BarEditItemThemeKeyExtension ResourceKey=Template} control template. In this template, bind the Visibility property of the "PART_Content" element to a custom property in the following manner:

[XAML]
<dxc:MeasurePixelSnapperContentControlx:Name="PART_Content"Visibility="{Binding Path=Link.(dxm:BarEditItemMode.IsCaptionVisible), ...}".../>

Alternatively, this functionality can be implemented by setting the BarItemLinkControl.ActualShowContentProperty property to False.

Starting with v2012 vol 2 we have changed templates of BarItemLinkControl and its descendants (see the BC1768 breaking change to get more information). In this version, the item's content can be hided by overriding the BarEditItemLinkControl.UpdateLayoutPanelShowContent method in the following manner:

[C#]
publicclassMyBarEditItemLinkControl:BarEditItemLinkControl{protectedoverridevoidUpdateLayoutPanelShowContent(){if(LayoutPanel!=null)LayoutPanel.ShowContent=((MyBarEditItemLink)Link).IsCaptionVisible;}}


To learn more on how to implement a similar functionality in Silverlight, refer to the T246748 example.


MVVM - How to bind the GridControl's selected rows to a property in a ViewModel

$
0
0

This example demonstrates how to bind GridControl's selected rows to a property in ViewModel in a MVVM-based application. The SelectionAttachedBehavior helper class used in this sample, provides a bindable SelectedItemsSource property, that can be used to define selection at the ViewModel level.

Note, we made the SelectionAttachedBehavior class as generic as possible, and the same approach can also be used for other controls that support multiple selection. This example demonstrates how this can be done when working with the standard ListBox control, as well as with the standard DataGrid.

To learn more on how to implement similar functionality in WPF, refer to the E3139 example.

MVVM - How to bind the GridControl's selected rows to a property in a ViewModel

$
0
0

This example demonstrates how to bind GridControl's selected rows to a property in ViewModel in a MVVM-based application. The SelectionAttachedBehavior helper class used in this sample, provides a bindable SelectedItemsSource property, that can be used to define selection at the ViewModel level.

Note, we made the SelectionAttachedBehavior class as generic as possible, and the same approach can also be used for other controls that support multiple selection. This example demonstrates how this can be done when working with the standard ListBox control, as well as with the standard DataGrid.

To learn more on how to implement similar functionality in Silverlight, refer to the T246827 example.

Question Comments

Added By: S Sharma at: 12/18/2012 10:27:47 PM    

Hi

I am using this procedure to preserve selected rows for the WPF GridControl, but as we are updating the grid with new data in a timer, the selected rows are still getting lost. Please suggest how should we modify this sample so as to preserve grid selected rows even between the updates (like same selected rows should be present after the grid is updated with new data in a separate thread). Also, We are using a NavigationStyle=Cell, so just wanted to also check if we need to change the NavigationStyle to Row for your below sample to work with grid updates?

Thanks

Added By: Vidhyadhar Dhumal at: 3/25/2014 8:27:13 AM    

In this example how to avoid multiple selection of rows. Our requirement is user should not be able to select mutiple rows. only single row should be allowed ro select. Hope this clarifies our requirement.

Added By: Michael Ch (DevExpress Support) at: 5/26/2015 7:06:46 AM    

Hello Vidhyadhar Dhumal,

We accidentally discovered that your initial post was outside the scope of our Support Center. Please accept our sincere apologies for not responding in a timely manner.
If this task is still important for you, find a couple of minutes to refer to the Q581629 thread. To implement the required selection mode, use the SelectionMode property as described in the Multiple Row Selection topic. To learn more about selection capabilities of the GridControl, refer to Selection.

The issue with losing the selection during updating the grid was discussed in Q452866, you can find all information there.

MVVM - How to bind GridColumn properties to properties in a ViewModel

$
0
0

This example shows how to bind column properties and properties of column's EditSettings to properties in the ViewModel in a MVMM-based application. Additionally, the sample demonstrates how to manipulate these properties in XAML using binding by element name.

To learn more on how to implement a similar functionality in Silverlight, refer to the T246782 example.

How to use the IMVVMDockingProperties interface in an MVVM application

$
0
0

This example demonstrates how to use the DXDocking IMVVMDockingProperties interface. This interface provides you a way to specify target groups for each of your view models.

For more information on how to implement this task in WPF, see E20026.

How to customize a message dialog displayed when runtime errors occur

$
0
0

This example demonstrates how to display a custom message in a custom manner instead of the default user warning dialog box.
Сreate a class that implements the IMessageBox service and register that class in place of the default service by using the SpreadsheetControl.ReplaceService method.
The IMessageBox service provides the ShowOkCancelMessage, ShowWarningMessage, ShowYesNoMessage,  ShowMessageShowDataValidationDialog methods which are called in specific situations when the SpreadsheetControl needs user attention.

XRTable - How to best fit columns

$
0
0

Currently, XRTable does not provide the best fit column functionality for several reasons. It is not quite clear how this feature should work in the case of multi-line text in cells. Being applied to a grid, the best-fit feature resizes grid columns so you can use the horizontal scrollbar to reach all of them. Reports does not provide interactivity like content scrolling and it is difficult to foresee how a user would want to change the report layout in the case of large column content. 

For these reasons, a generic solution is not always possible. However, we can implement this manually if required. This example demonstrates how to do so. 

Here are implementation details.
1. Create a document by using the Report's CreateDocument Method.
2. Iterate through all report bricks to obtain the maximum text width within a certain column.
Since XRTable rows act independently and know nothing about each other, to detect the max width of the text in a certain column, we need to iterate through report table bricks manually (for instance, using BricksIterator) and calculate the text width (using the PrintingSystem.Graph.MeasureString method).
3. Re-set the XRTableCell's WidthF property according to calculation results.
4. Re-create the report document.

See also:
How to set the label width so that it is always equal to its text (AutoWidth)

How to use XPO in ASP.NET MVC3 application (Razor)

$
0
0

This example demonstrating a simple ASP.NET MVC3 application using XPO as Data Access Layer.

See also: How to use XPO in an ASP.NET MVC application

Question Comments

Added By: TPS Programmer at: 11/3/2014 2:38:52 AM    

how to convert this syntaks

@model IEnumerable<CustomerViewModel>
@Html.Partial("IndexPartial", Model);

into vb syntax ?

Added By: TPS Programmer at: 11/3/2014 2:40:10 AM    

almost forget, because in VB source code, index.cshtml still in C#, not in VBHTML

Added By: Anthony (DevExpress Support) at: 11/3/2014 5:01:27 AM    

Hi,

The code would be as follows:

[VB.NET]
@ModelType IEnumerable(Of CustomerViewModel) @Html.Partial("IndexPartial", Model)

As for the example, we will correct the syntax as soon as possible.

Added By: Larry Kingsbury at: 5/26/2015 11:16:52 AM    

It sure would be nice if you would upgrade your examples to the current version of MircoSoft and DevExpress products.  When I tried to run the Example from here in VS 2013 using MVC 4, it had to convert to the current version and then I had to play with references and I finally ended up with this stack dump:
System.TypeInitializationException was unhandled by user code
 HResult=-2146233036
 Message=The type initializer for 'XpoHelper' threw an exception.
 Source=DevExpressMvcApplication
 TypeName=XpoHelper
 StackTrace:
      at XpoHelper.GetNewUnitOfWork()
      at DevExpressMvcApplication.Controllers.BaseXpoController`1.CreateSession() in c:\Visual Studios\DevExpressMvcApplication\Controllers\BaseXpoController.cs:line 18
      at DevExpressMvcApplication.Controllers.BaseXpoController`1..ctor() in c:\Visual Studios\DevExpressMvcApplication\Controllers\BaseXpoController.cs:line 10
      at DevExpressMvcApplication.Controllers.CustomersController..ctor()
 InnerException: DevExpress.Xpo.DB.Exceptions.UnableToOpenDatabaseException
      HResult=-2146233088
      Message=Unable to open database. Connection string: 'data source=.;initial catalog=XPOMVXExampleEditable;integrated security=sspi;'; Error: 'System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
  at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
  at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
  at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover, SqlAuthenticationMethod authType)
  at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
  at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
  at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
  at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken)
  at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
  at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
  at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
  at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
  at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
  at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
  at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
  at System.Data.SqlClient.SqlConnection.Open()
  at DevExpress.Xpo.DB.MSSqlConnectionProvider.CreateDataBase(SqlConnection conn)
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:2,State:0,Class:20'
      Source=DevExpress.Xpo.v14.2
      StackTrace:
           at DevExpress.Xpo.DB.MSSqlConnectionProvider.CreateDataBase(SqlConnection conn)
           at DevExpress.Xpo.DB.MSSqlConnectionProvider.CreateDataBase()
           at DevExpress.Xpo.DB.ConnectionProviderSql..ctor(IDbConnection connection, AutoCreateOption autoCreateOption)
           at DevExpress.Xpo.DB.MSSqlConnectionProvider..ctor(IDbConnection connection, AutoCreateOption autoCreateOption)
           at DevExpress.Xpo.DB.MSSqlConnectionProvider.CreateProviderFromString(String connectionString, AutoCreateOption autoCreateOption, IDisposable[]& objectsToDisposeOnDisconnect)
           at DevExpress.Xpo.DB.DataStoreBase.QueryDataStore(String providerType, String connectionString, AutoCreateOption defaultAutoCreateOption, IDisposable[]& objectsToDisposeOnDisconnect)
           at DevExpress.Xpo.XpoDefault.GetConnectionProvider(String connectionString, AutoCreateOption defaultAutoCreateOption, IDisposable[]& objectsToDisposeOnDisconnect)
           at DevExpress.Xpo.XpoDefault.GetDataLayer(String connectionString, XPDictionary dictionary, AutoCreateOption defaultAutoCreateOption, IDisposable[]& objectsToDisposeOnDisconnect)
           at DevExpress.Xpo.XpoDefault.GetDataLayer(String connectionString, AutoCreateOption defaultAutoCreateOption)
           at XpoHelper.UpdateDatabase() in c:\Visual Studios\DevExpressMvcApplication\Helpers\XpoHelper.cs:line 48
           at XpoHelper..cctor() in c:\Visual Studios\DevExpressMvcApplication\Helpers\XpoHelper.cs:line 12
      InnerException: System.Data.SqlClient.SqlException
           HResult=-2146232060
           Message=A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
           Source=.Net SqlClient Data Provider
           ErrorCode=-2146232060
           Class=20
           LineNumber=0
           Number=2
           Server=""
           State=0
           StackTrace:
                at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
                at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
                at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover, SqlAuthenticationMethod authType)
                at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
                at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
                at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
                at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken)
                at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
                at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
                at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
                at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
                at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
                at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
                at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
                at System.Data.SqlClient.SqlConnection.Open()
                at DevExpress.Xpo.DB.MSSqlConnectionProvider.CreateDataBase(SqlConnection conn)
           InnerException: System.ComponentModel.Win32Exception
                HResult=-2147467259
                Message=The system cannot find the file specified
                ErrorCode=-2147467259
                NativeErrorCode=2
                InnerException:

Can you post an already migrated version so I don't have to waste more hours?


How to use the IMVVMDockingProperties interface in an MVVM application

$
0
0

This example demonstrates how to use the DXDocking IMVVMDockingProperties interface. This interface provides you a way to specify target groups for each of your view models.

For more information on how to implement this task in Silverlight, see T246924.

How to bind the ASPxScheduler to the Oracle data base using the ObjectDataSource component (based on T223127)

$
0
0

This example demonstrates the approach described in the following KB article:
How to bind ASPxScheduler to the Oracle data base using the ObjectDataSource component (description)
To run this sample, you need to have an Oracle client installed on your machine and change connection string settings to the data base specified in the Web.config file

Question Comments

Added By: Muhammed Yasir at: 5/26/2015 11:10:25 PM    

how to control if the other appointment save on same existing one

Added By: Muhammed Yasir at: 5/26/2015 11:11:55 PM    

how to change the theme of popup window? when click for new appointment.

Added By: Oleg (DevExpress Support) at: 5/27/2015 2:08:50 AM    

Hello Muhammed,
To process your recent posts more efficiently, I created separate tickets on your behalf:
T247218: How to customize the Edit Appointment Form
T247219: How to prevent a conflicted appointment from being saved in a data source.  
These tickets are currently in our processing queue. Our team will address them as soon as we have any updates.

How to customize an XPO business model at runtime (Example)

$
0
0

Sometimes there is a requirement to extend existing business classes from other libraries, add new members, etc.

For instance, you have an assembly where you have declared your persistent classes. Now, you want to use these classes in your XAF application.

Note that to use the types from external assemblies, you should add them to your business model. To do that, you should use the Business Classes section of the Module Designer.


For instance, to force XAF to create navigation items for business classes, usually you can mark them with the DevExpress.Persistent.Base.DefaultClassOptionsAttribute, but what to do if your classes "live" in a separate assembly, which has no references to DevExpress.ExpressApp assemblies.

What to do? In this instance, the XafTypesInfo / XPDictionary customization may be helpful. Currently in XAF using this approach, you can add new attributes to your classes and their members, declare new associations, etc. The only thing, which is not currently supported in XAF, by default, is the capability to declare new classes "on the fly" via customization of the XafTypesInfo / XPDictionary. 

IMPORTANT NOTES

1. By design you cannot dynamically add or remove the OptimisticLocking and DeferredDeletion attributes.
2. Adding custom members for Domain Components (DC) should be done on the XafApplication.SettingUp event as described at How do I define a custom member for a domain component (DC) at runtime?.
3. You cannot dynamically establish an association between two persistent classes via the XafTypesInfo API. Use the XPDictionary API instead.


See also:
How to: Access Business Class Metadata

Question Comments

Added By: Denis S at: 11/15/2013 5:58:17 AM    

Update the MyXPOClassLibrary project from Framework 3.0 to 4.0, in order to compile.

How to highlight the focused editor in DetailView

$
0
0

Scenario
In this example, it is demonstrated how highlight focused editors in an editable DetailView for both Windows and the Web:

Additionally, the following Model Editor extensions are implemented for more convenience:
 - The HighlightFocusedLayoutItem attribute at the Application | Options node level allows you to control this functionality globally per application via the Model Editor.
 - The HighlightFocusedLayoutItem attribute at the Views | DetailView node level allows you to customize only certain DetailViews via the Model Editor



Steps to implement
1. Modify YourSolutionName.Module/Module.xx file as shown in the WinWebSolution.Module\Module.xx file of this example.
Note: The approach from the eXpressApp Framework > Concepts > Application Model > Extend and Customize the Application Model in Code article is used here.

2. Copy the WinWebSolution.Module\HighlightFocusedLayoutItemDetailViewControllerBase.xx file into the YourSolutionName.Module project.
Note: The approaches from the eXpressApp Framework > Concepts > Application Model > Access the Application Model in Code and Controller.Active Property articles is used here.

3. Copy the WinWebSolution.Module.Win\HighlightFocusedLayoutItemDetailViewController.xx file into the YourSolutionName.Module.Win project.
Note: In Windows Forms applications, the functionality is provided with the help of the LayoutControl and its HighlightDisabledItem and AllowItemSkinning options. The approach from the eXpressApp Framework > Concepts > UI Construction > View Items Layout Customization article is used to access LayoutControl.

4. Copy the WinWebSolution.Module.Web\HighlightFocusedLayoutItemDetailViewController.xx file into the YourSolutionName.Module.Web project. Then copy the WinWebSolution.Web\E2106.js file into the YourSolutionName.Web project.
Finally, add the <script type="text/javascript" src="E2106.js"></script> line into the <head> element of your YourSolutionName.Web\Default.aspx file.
Note: In ASP.NET applications, the functionality is implemented manually as per How to highlight a focused editor via client-side scripting via client-side events provided by our ASP.NET editors. The approach from the eXpressApp Framework > Getting Started > Comprehensive Tutorial (MainDemo Application) > Extend Functionality > Access Editor Settings article is used to access PropertyEditor controls.


IMPORTANT NOTES
It is possible to register your JavaScript functions at runtime via the DevExpress.ExpressApp.Web.WebWindow.CurrentRequestWindow.RegisterXXXScript methods called from a Controller when it is activated or when page controls are created. Refer to the How to automatically refresh data in a View after a certain period of time on the Web article for an illustration of this approach.

See Also:
Usability - highlight the focused editor in detail views

Question Comments

Added By: tzanis tasos at: 1/27/2015 11:52:22 AM    

Hello,
In version V2014 14.2.4.0 this sample not work on web. It works only for combobox and not for other controls.
When i run the sample in debug mode, the existingHandler return empty string when eventName="GotFocus"
string existingHandler = control.GetClientSideEventHandler(eventName);

Added By: Dennis (DevExpress Support) at: 1/28/2015 9:14:33 AM    @Tzanis: Thanks for your report. I will answer you in T201753.Added By: Carlitos at: 3/15/2015 4:16:47 PM    

I like this. Does it work when using E2034,?

Added By: Dennis (DevExpress Support) at: 3/16/2015 5:26:02 AM    @Carlitos: No, because the E2034 example disables skinning.Added By: Abel Acosta 1 at: 4/30/2015 10:46:42 AM    

Hi DevExp Team,

I Have tried to implement this nice functionality, its works fine while i am running both xaf windows form and web application, from Visual Studio. However, when i deploy the windows form  application its fail.

it says.

Exception Occurs while assigning the 'DetailView, ID: BussinessClass_DetailView' view to WinWindow
Unabled To Cast object of type 'ModelDetailView' to type 'Solution.Module.IModelDetailViewHightlightFocusedLayoutItem'.

What i am missing or doing wrong? The web application works fine even deployed.

Added By: Dennis (DevExpress Support) at: 4/30/2015 1:54:57 PM    @Abel: According to the error message you have missed the first step from the Steps to Implement section above.

How to convert and then print an GridView extension by using the XtraReport

$
0
0

This example demonstrates how to dynamically create a report based upon the GridView extension at runtime. This means that all filtering, sorting and grouping conditions selected in the grid are also applied in a report. To accomplish this task, it is necessary to create a report with all the necessary bands, bind it to a data source and adjust all the necessary options. You can use this approach if you need to display content of templated columns in your report or insert a report based on GridView to another report.
As it is impossible to get the GridView extension state (its filtering, groping, sorting info), the Session is used to pass the last GridView state to the controller.

See also:
E4476: How to convert and then print an ASPxGridView by using the XtraReport

Question Comments

Added By: Kiran Pratapagiri at: 7/3/2013 12:46:27 AM    

Hi,
Thanks for the example.

I think I found the problem with this example. It's not exporting the last column of the Grid.
Please correct the example to export the last column into report.

Thanks

Added By: Diogo Azevedo 1 at: 10/24/2013 8:23:13 AM    

this example works for version 2012?

Added By: Vasily (DevExpress Support) at: 10/24/2013 11:31:20 PM    

Yes, this example should work with version 2012. Anyway, if you face any issues after converting this example to version 2012, please feel free to create a separate support ticket for this issue.

Added By: Nick Hoare at: 7/22/2014 9:28:47 AM    

In ReportHelper.vb, in InitDetailsandPageheader cell.Text is set to the FieldName where I think it should really be set to the ColumnCaption to make use of the work done in GetColumnsInfo which selects the ColumnCaption to be the Caption if there is one or FieldName if there isn't.  It certainly works better for me.  This affects C#,  VB and ASPxGridView example code.
                  
cell.Width = columns(i).ColumnWidth
cell.Text = columns(i).ColumnCaption  'Better to show the Caption than the examples columns(i).FieldName
row.Cells.Add(cell

Added By: Vasily (DevExpress Support) at: 7/23/2014 5:56:06 AM    Hi Nick,

Thank you for your feedback. This example demonstrates how to generate an XtraReport from ASPxGridView, so we will not change its code now. 
Anyway, feel free to modify the code provided in this example according to your scenario. 

Added By: Ben Hugh Riches at: 5/27/2015 8:13:17 AM    

Hi,

Is it possible to get a VS project version of this example, using a List<T> as the data source and stripped to the core GridView to Report functionality?

Regards,

Ben

Added By: Paul (DevExpress Support) at: 5/27/2015 11:14:42 AM    Hi,

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T247668: Is it possible to get a VS project version of the E4755 example. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to search and focus nodes in the Tree List editor

$
0
0

This example demonstrates how to use recursion to search and focus a node in the TreeList.

It contains a custom controller (FilterTreeListViewController) that extends the default behavior of the FilterController.FullTextFilterAction for ListViews with hierarchical data.

Once you searched for a value using the built-in search, you can press F3 to move between nodes that contain the same value.

Question Comments

Added By: John Whattam 1 at: 6/17/2013 6:50:46 PM    

Where's the recursion?

Added By: Andrew Bingham 2 at: 11/3/2013 10:23:19 PM    

Goes into an inifinite loop

How to create and populate an unbound column

$
0
0

GridView does not cache values of an unbound column, because it is impossible to determine when the cache should be cleared automatically. GridView just displays values provided by the CustomUnboundColumnData event. So, to display a specific value in a cell, you need to pass a corresponding value to the e.Value parameter based on a processed column and row. What you return as the e.Value parameter is what is displayed in GridView. Each time a cell needs to be updated, the CustomUnboundColumnData event is called.

This example demonstrates how a simple caching mechanism can be implemented. In this project, you can perform all supported operations with GridView, such as sorting/deleting/adding records, and the unbound column will display proper values. This is because values of the ID column are used as key values. This column is readonly and contains only unique values. So, rows can be always identified.

Question Comments

Added By: Boris Soto at: 11/24/2012 3:13:02 PM    

When using code I get following error
Error     1     'InitializeComponent' is not declared. It may be inaccessible due to its protection level.     C:\Users\Boris\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb     32     13     WindowsApplication1
Error     2     'gridControl1' is not declared. It may be inaccessible due to its protection level.     C:\Users\Boris\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb     34     13     WindowsApplication1
Error     3     'gridView1' is not declared. It may be inaccessible due to its protection level.     C:\Users\Boris\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb     38     37     WindowsApplication1
Error     4     Handles clause requires a WithEvents variable defined in the containing type or one of its base types.     C:\Users\Boris\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb     44     156     WindowsApplication1
 Please advice

Added By: Mathias Tenaye Sahile at: 12/24/2014 12:54:27 AM    

i tried but was not sucessfull when is this
   Private Sub gridView1_CustomUnboundColumnData(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs) Handles gridView1.CustomUnboundColumnData
           If e.IsGetData Then
               e.Value = _Cache.GetValue(e.Row)
           End If
           If e.IsSetData Then
               _Cache.SetValue(e.Row, e.Value)
           End If
       End Sub
called do and how

Added By: Olga (DevExpress Support) at: 12/24/2014 2:18:48 AM    Hello,
As I can see, you've created a separate ticket on this subject. I've moved your comment there. Let's continue our discussion in that thread.Added By: Paul Riddell at: 1/5/2015 9:44:49 AM    

Hi are there any examples of this using an xpcollection of xpobjects as the datasource?

Added By: Dimitros (DevExpress Support) at: 1/6/2015 3:24:00 AM    

Hello Johnathon ,

To process your recent post more efficiently, I created a separate ticket on your behalf: T193371: Unbound column - how to use with XPCollection. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Dirk Dumon 1 at: 5/28/2015 12:43:44 AM    

Hi, I tried implementing this but the method gridView1_CustomUnboundColumnData is never triggered with IsSetData = true.
Only IsGetData is triggered.
In this regard, I found https://www.devexpress.com/Support/Center/Question/Details/CB65344
So, is this sample not correct or is there a way to get the IsSetData to work?

Added By: Nadezhda (DevExpress Support) at: 5/28/2015 2:26:29 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: How to set the CustomColumnDataEventArgs.IsSetData property to true . This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.


How to set the text max length in the ASPxMemo control

$
0
0

This example shows how to set the text max length in the ASPxMemo control.

If an end-user types in text or pastes it by using a corresponding shortcut, you can crop the text in the KeyDown event handler when its length exceeds the max value. If the end-user pastes text to ASPxMemo by using the context menu, you can crop the text in the “paste” event handler of the ASPxMemo “textarea” element. We disable the context menu for ASPxMemo in the Opera browser because it doesn’t provide the “paste” event.

See also:

ASPxMemo - How to limit the length of text that can be entered into the control using MaxLength
How to implement the "characters remaining" functionality for ASPxTextBox and ASPxMemo using MaxLength

Question Comments

Added By: James Parker at: 11/16/2012 7:43:59 AM    

ClientInstanceName is missing from the ASPxMemo in the sample code. It should be:

 <dx:ASPxMemo ID="memo" runat="server" Height="71px" Width="170px" ClientInstanceName="memo">
<ClientSideEvents Init="memo_OnInit" KeyDown="memo_OnKeyDown" />

Added By: Alonso Torres at: 5/28/2015 12:39:35 PM    

Besides lots of errors on this script, it will allow to type lowercase 'z' and numbers with the Numeric Pad even if maxLength has already been reached!!
I have changed it to somgething like:
     function memo_OnKeyDown(s, e) {
           if (s.GetText().length >= se.GetNumber())
               CorrectTextWithDelay();
           // Ctrl + V
           if (e.htmlEvent.keyCode === 86 && e.htmlEvent.ctrlKey)
               CorrectTextWithDelay();
       }

Added By: Alonso Torres at: 5/28/2015 12:45:36 PM    

I've changed the script so the maxLength value does not get taken from the SpinEdit control, but from a variable. I've also make use of the s parameter to target the sender instead of using the ClientInstanceName value:

       var memoMaxLength = 1000;

       function memo_OnKeyDown(s, e) {
           if (s.GetText().length >= memoMaxLength)
               CorrectTextWithDelay(s);
           // Ctrl + V
           if (e.htmlEvent.keyCode === 86 && e.htmlEvent.ctrlKey)
               CorrectTextWithDelay(s);
       }

       function memo_OnInit(s, e) {
           var input = s.GetInputElement();
           if (ASPxClientUtils.opera)
               input.oncontextmenu = function () { return false; };
           else
               input.onpaste = function () { CorrectTextWithDelay(s); };
       }

       function CorrectTextWithDelay(s) {
           setTimeout(function () { s.SetText(s.GetText().substr(0, memoMaxLength)); }, 0);
       }

ASPxGridView - How to sort the columns placed in the CustomizationWindow based on their visible index

$
0
0

By design, ASPxGridView orders columns in CustomizationWindow based on a column's caption. Thus, it is necessary to change the column caption to change its order in the CustomizationWindow. Adding an index before the caption allows you to set the custom column order:

[C#]
protectedvoidgridView_BeforeGetCallbackResult(objectsender,EventArgse){intcurrentIndex= 0;foreach(GridViewDataColumncolumningridView.DataColumns){if(column.Visible==false)currentIndex++;stringcaption=System.Text.RegularExpressions.Regex.Replace(column.FieldName,"(?=[A-Z][a-z])|(?<=[a-z])(?=[A-Z])"," ",System.Text.RegularExpressions.RegexOptions.Compiled).Trim();column.Caption=!column.Visible?string.Format("{0}) {1}",currentIndex.ToString("D2"),caption):caption;}}

How to conditionally change control appearance

$
0
0

This example demonstrates how to conditionally change control appearance at runtime. For this, it is necessary to create an instance of the FormattingRule class, specify its Condition and Formatting properties and add this objects to a report's sheet of formatting rules (XtraReport.FormattingRuleSheet) and to the collection of formatting rules of a control or a band, to which it should be applied (XRControl.FormattingRules).

ASPxGridView - Cell Merging

$
0
0

The example shows how to implement the cell merge feature for the ASPxGridView control.
You can use the helper class that will perform cell merging for the grouped grid as well.
Please keep in mind that functionality such as row selection, in-place editing and focused row may not work as expected which is understandable.

Question Comments

Added By: Seonkyeong Min at: 5/11/2015 2:23:37 PM    

Hello, This example is not working well.

First Line is complex.

other lines is works.

i wanna attach an image file.
but i cant upload the image because you guys doesn't have upload file function.

Added By: Larry (DevExpress Support) at: 5/12/2015 12:33:07 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T240441: ASPxGridView - Issue with a cell merging. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Jay Gamblin at: 5/29/2015 10:41:37 AM    

This does not appear to work with 14.2.5.  I get  'ASPxClientTableFixedColumnsHelper' is undefined

How to create a WinExplorerView descendant class and register it for design-time use

$
0
0

This is an example of a custom WinExplorerView and a custom control that inherits the DevExpress.XtraGrid.GridControl. Make sure to build the project prior to opening Form1 in the designer.

To obtain general information about creating and registering a custom view descendant class at design time, refer to the following Knowledge Base article: How to create a GridView descendant class and register it for design-time use.

Question Comments

Added By: Daniel Kaminski at: 5/30/2015 10:15:48 AM    

Could you please make this example available in VS2010?
Thanks!

Viewing all 7205 articles
Browse latest View live


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